Class: Fog::Proxmox::Storage::Real
- Inherits:
-
Object
- Object
- Fog::Proxmox::Storage::Real
show all
- Includes:
- Core
- Defined in:
- lib/fog/proxmox/storage.rb,
lib/fog/proxmox/storage/requests/list.rb,
lib/fog/proxmox/storage/requests/create.rb,
lib/fog/proxmox/storage/requests/upload.rb,
lib/fog/proxmox/storage/requests/list_appliances.rb,
lib/fog/proxmox/storage/requests/download_appliance.rb
Overview
class Real download_appliance
Instance Attribute Summary
Attributes included from Core
#auth_method, #current_user, #expires, #token
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Core
#credentials, #initialize, #reload, #setup, #user_token?
Class Method Details
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/fog/proxmox/storage/requests/upload.rb', line 23
def self.build_formdata(body_params)
boundary = '-' * 30 + SecureRandom.hex(15)
body = "--#{boundary}" + Excon::CR_NL
body << 'Content-Disposition: form-data; name="content"' << Excon::CR_NL << Excon::CR_NL
body << body_params[:content] << Excon::CR_NL
body << "--#{boundary}" << Excon::CR_NL
body << %(Content-Disposition: form-data; name="filename"; filename="#{body_params[:filename]}") << Excon::CR_NL
body << 'Content-Type: ' << (body_params[:content_type] || 'application/octet-stream') << Excon::CR_NL << Excon::CR_NL
body << body_params[:file].read << Excon::CR_NL
body << "--#{boundary}--" << Excon::CR_NL
[body, %(multipart/form-data; boundary=#{boundary})]
end
|
.not_found_class ⇒ Object
60
61
62
|
# File 'lib/fog/proxmox/storage.rb', line 60
def self.not_found_class
Fog::Proxmox::Storage::NotFound
end
|
Instance Method Details
#config ⇒ Object
64
65
66
|
# File 'lib/fog/proxmox/storage.rb', line 64
def config
self
end
|
#config_service? ⇒ Boolean
68
69
70
|
# File 'lib/fog/proxmox/storage.rb', line 68
def config_service?
true
end
|
#create(body_params) ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/fog/proxmox/storage/requests/create.rb', line 8
def create(body_params)
request(
expects: [200],
method: 'POST',
path: "storage",
body: URI.encode_www_form(body_params)
)
end
|
#download_appliance(path_params, body_params) ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/fog/proxmox/storage/requests/download_appliance.rb', line 8
def download_appliance(path_params, body_params)
node = path_params[:node]
request(
expects: [200],
method: 'POST',
path: "nodes/#{node}/aplinfo",
body: URI.encode_www_form(body_params)
)
end
|
#list(options = {}) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/fog/proxmox/storage/requests/list.rb', line 8
def list(options = {})
request(
expects: [200],
method: 'GET',
path: "storage"
)
end
|
#list_appliances(options) ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/fog/proxmox/storage/requests/list_appliances.rb', line 8
def list_appliances(options)
node = options[:node]
request(
expects: [200],
method: 'GET',
path: "nodes/#{node}/aplinfo"
)
end
|
#upload(path_params, body_params) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/fog/proxmox/storage/requests/upload.rb', line 10
def upload(path_params, body_params)
node = path_params[:node]
storage = path_params[:storage]
body, content_type = self.class.build_formdata(body_params)
request(
expects: [200],
method: 'POST',
path: "nodes/#{node}/storage/#{storage}/upload",
body: body,
headers: { 'Content-Type' => content_type }
)
end
|