Class: Fog::Proxmox::Compute::Real

Inherits:
Object
  • Object
show all
Includes:
Fog::Proxmox::Core
Defined in:
lib/fog/compute/proxmox.rb,
lib/fog/compute/proxmox/requests/get_vnc.rb,
lib/fog/compute/proxmox/requests/get_task.rb,
lib/fog/compute/proxmox/requests/log_task.rb,
lib/fog/compute/proxmox/requests/move_disk.rb,
lib/fog/compute/proxmox/requests/next_vmid.rb,
lib/fog/compute/proxmox/requests/stop_task.rb,
lib/fog/compute/proxmox/requests/create_vnc.rb,
lib/fog/compute/proxmox/requests/get_volume.rb,
lib/fog/compute/proxmox/requests/list_nodes.rb,
lib/fog/compute/proxmox/requests/list_tasks.rb,
lib/fog/compute/proxmox/requests/create_term.rb,
lib/fog/compute/proxmox/requests/move_volume.rb,
lib/fog/compute/proxmox/requests/status_task.rb,
lib/fog/compute/proxmox/requests/clone_server.rb,
lib/fog/compute/proxmox/requests/create_spice.rb,
lib/fog/compute/proxmox/requests/list_servers.rb,
lib/fog/compute/proxmox/requests/list_volumes.rb,
lib/fog/compute/proxmox/requests/action_server.rb,
lib/fog/compute/proxmox/requests/create_backup.rb,
lib/fog/compute/proxmox/requests/create_server.rb,
lib/fog/compute/proxmox/requests/delete_server.rb,
lib/fog/compute/proxmox/requests/delete_volume.rb,
lib/fog/compute/proxmox/requests/list_storages.rb,
lib/fog/compute/proxmox/requests/resize_server.rb,
lib/fog/compute/proxmox/requests/update_server.rb,
lib/fog/compute/proxmox/requests/list_snapshots.rb,
lib/fog/compute/proxmox/requests/migrate_server.rb,
lib/fog/compute/proxmox/requests/create_snapshot.rb,
lib/fog/compute/proxmox/requests/delete_snapshot.rb,
lib/fog/compute/proxmox/requests/template_server.rb,
lib/fog/compute/proxmox/requests/update_snapshot.rb,
lib/fog/compute/proxmox/requests/resize_container.rb,
lib/fog/compute/proxmox/requests/get_server_config.rb,
lib/fog/compute/proxmox/requests/get_server_status.rb,
lib/fog/compute/proxmox/requests/rollback_snapshot.rb,
lib/fog/compute/proxmox/requests/get_node_statistics.rb,
lib/fog/compute/proxmox/requests/get_snapshot_config.rb

Overview

class Real get_snapshot_config request

Instance Attribute Summary

Attributes included from Fog::Proxmox::Core

#deadline, #principal, #pve_csrftoken, #pve_ticket, #pve_username

Instance Method Summary collapse

Methods included from Fog::Proxmox::Core

#credentials, #initialize_identity, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



114
115
116
117
118
119
120
121
122
# File 'lib/fog/compute/proxmox.rb', line 114

def initialize(options = {})
  initialize_identity(options)
  @connection_options = options[:connection_options] || {}
  @path_prefix = URI.parse(options[:pve_url]).path
  authenticate
  @persistent = options[:persistent] || false
  url = "#{@scheme}://#{@host}:#{@port}"
  @connection = Fog::Core::Connection.new(url, @persistent, @connection_options.merge(path_prefix: @path_prefix))
end

Instance Method Details

#action_server(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/compute/proxmox/requests/action_server.rb', line 25

def action_server(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  action = path_params[:action]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/status/#{action}",
    body: URI.encode_www_form(body_params)
  )
end

#clone_server(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/clone_server.rb', line 25

def clone_server(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/clone",
    body: URI.encode_www_form(body_params)
  )
end

#create_backup(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/fog/compute/proxmox/requests/create_backup.rb', line 25

def create_backup(path_params, body_params)
  node = path_params[:node]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/vzdump",
    body: URI.encode_www_form(body_params)
  )
end

#create_server(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/proxmox/requests/create_server.rb', line 25

def create_server(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}",
    body: URI.encode_www_form(body_params)
  )
end

#create_snapshot(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/create_snapshot.rb', line 25

def create_snapshot(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/snapshot",
    body: URI.encode_www_form(body_params)
  )
end

#create_spice(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/create_spice.rb', line 25

def create_spice(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/spiceproxy",
    body: URI.encode_www_form(body_params)
  )
end

#create_term(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/create_term.rb', line 25

def create_term(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/termproxy",
    body: URI.encode_www_form(body_params)
  )
end

#create_vnc(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/create_vnc.rb', line 25

def create_vnc(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/vncproxy",
    body: URI.encode_www_form(body_params)
  )
end

#delete_server(path_params, body_params) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/compute/proxmox/requests/delete_server.rb', line 26

def delete_server(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'DELETE',
    path: "nodes/#{node}/#{type}/#{vmid}",
    body: URI.encode_www_form(body_params)
  )
end

#delete_snapshot(path_params, query_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/compute/proxmox/requests/delete_snapshot.rb', line 25

def delete_snapshot(path_params, query_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  snapname = path_params[:snapname]
  request(
    expects: [200],
    method: 'DELETE',
    path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}",
    query: URI.encode_www_form(query_params)
  )
end

#delete_volume(node, storage, volume) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/fog/compute/proxmox/requests/delete_volume.rb', line 25

def delete_volume(node, storage, volume)
  request(
    expects: [200],
    method: 'DELETE',
    path: "nodes/#{node}/storage/#{storage}/content/#{volume}"
  )
end

#get_node_statistics(path_params, query_params) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/get_node_statistics.rb', line 26

def get_node_statistics(path_params, query_params)
  node = path_params[:node]
  output = path_params[:output]
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/#{output}",
    query: URI.encode_www_form(query_params)
  )
end

#get_server_config(path_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/proxmox/requests/get_server_config.rb', line 25

def get_server_config(path_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/#{type}/#{vmid}/config"
  )
end

#get_server_status(path_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/proxmox/requests/get_server_status.rb', line 25

def get_server_status(path_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/#{type}/#{vmid}/status/current"
  )
end

#get_snapshot_config(path_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/get_snapshot_config.rb', line 25

def get_snapshot_config(path_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  snapname = path_params[:snapname]
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}/config"
  )
end

#get_task(node, upid) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/fog/compute/proxmox/requests/get_task.rb', line 26

def get_task(node, upid)
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/tasks/#{upid}"
  )
end

#get_vnc(path_params, query_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/get_vnc.rb', line 25

def get_vnc(path_params, query_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [101, 200],
    method: 'GET',
    path: "nodes/#{node}/#{type}/#{vmid}/vncwebsocket",
    query: URI.encode_www_form(query_params)
  )
end

#get_volume(node, storage, volume) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/fog/compute/proxmox/requests/get_volume.rb', line 27

def get_volume(node, storage, volume)
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/storage/#{storage}/content/#{volume}"
  )
end

#list_nodesObject



26
27
28
29
30
31
32
# File 'lib/fog/compute/proxmox/requests/list_nodes.rb', line 26

def list_nodes
  request(
    expects: [200],
    method: 'GET',
    path: 'nodes'
  )
end

#list_servers(options) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/fog/compute/proxmox/requests/list_servers.rb', line 25

def list_servers(options)
  node = options[:node]
  type = options[:type]
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/#{type}"
  )
end

#list_snapshots(path_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/proxmox/requests/list_snapshots.rb', line 25

def list_snapshots(path_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/#{type}/#{vmid}/snapshot"
  )
end

#list_storages(node, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/list_storages.rb', line 28

def list_storages(node, options = {})
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/storage",
    query: URI.encode_www_form(options)
  )
end

#list_tasks(node, options) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/fog/compute/proxmox/requests/list_tasks.rb', line 26

def list_tasks(node, options)
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/tasks",
    query: URI.encode_www_form(options)
  )
end

#list_volumes(node, storage, options) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/fog/compute/proxmox/requests/list_volumes.rb', line 26

def list_volumes(node, storage, options)
  request(
    expects: [200],
    method: 'GET',
    path: "/nodes/#{node}/storage/#{storage}/content",
    query: URI.encode_www_form(options)
  )
end

#log_task(node, upid, options) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/fog/compute/proxmox/requests/log_task.rb', line 26

def log_task(node, upid, options)
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/tasks/#{upid}/log",
    query: URI.encode_www_form(options)
  )
end

#migrate_server(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/migrate_server.rb', line 25

def migrate_server(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/migrate",
    body: URI.encode_www_form(body_params)
  )
end

#move_disk(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/proxmox/requests/move_disk.rb', line 25

def move_disk(path_params, body_params)
  node = path_params[:node]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/qemu/#{vmid}/move_disk",
    body: URI.encode_www_form(body_params)
  )
end

#move_volume(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/proxmox/requests/move_volume.rb', line 25

def move_volume(path_params, body_params)
  node = path_params[:node]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/lxc/#{vmid}/move_volume",
    body: URI.encode_www_form(body_params)
  )
end

#next_vmid(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/fog/compute/proxmox/requests/next_vmid.rb', line 26

def next_vmid(options = {})
  request(
    expects: [200],
    method: 'GET',
    path: 'cluster/nextid',
    query: URI.encode_www_form(options)
  )
end

#resize_container(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/proxmox/requests/resize_container.rb', line 25

def resize_container(path_params, body_params)
  node = path_params[:node]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'PUT',
    path: "nodes/#{node}/lxc/#{vmid}/resize",
    body: URI.encode_www_form(body_params)
  )
end

#resize_server(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/proxmox/requests/resize_server.rb', line 25

def resize_server(path_params, body_params)
  node = path_params[:node]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'PUT',
    path: "nodes/#{node}/qemu/#{vmid}/resize",
    body: URI.encode_www_form(body_params)
  )
end

#rollback_snapshot(path_params) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/compute/proxmox/requests/rollback_snapshot.rb', line 27

def rollback_snapshot(path_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  snapname = path_params[:snapname]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}/rollback"
  )
end

#status_task(node, upid) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/fog/compute/proxmox/requests/status_task.rb', line 26

def status_task(node, upid)
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/tasks/#{upid}/status"
  )
end

#stop_task(node, upid) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/fog/compute/proxmox/requests/stop_task.rb', line 26

def stop_task(node, upid)
  request(
    expects: [200],
    method: 'DELETE',
    path: "nodes/#{node}/tasks/#{upid}"
  )
end

#template_server(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/template_server.rb', line 25

def template_server(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/#{type}/#{vmid}/template",
    body: URI.encode_www_form(body_params)
  )
end

#update_server(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/proxmox/requests/update_server.rb', line 25

def update_server(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  request(
    expects: [200],
    method: type == 'qemu' ? 'POST' : 'PUT',
    path: "nodes/#{node}/#{type}/#{vmid}/config",
    body: URI.encode_www_form(body_params)
  )
end

#update_snapshot(path_params, body_params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/compute/proxmox/requests/update_snapshot.rb', line 25

def update_snapshot(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  snapname = path_params[:snapname]
  request(
    expects: [200],
    method: 'PUT',
    path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}/config",
    body: URI.encode_www_form(body_params)
  )
end