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

Inherits:
Object
  • Object
show all
Includes:
Proxmox::Core
Defined in:
lib/fog/compute/proxmox.rb,
lib/fog/compute/proxmox/requests/get_vnc.rb,
lib/fog/compute/proxmox/requests/get_node.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/check_vmid.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/get_storage.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/get_snapshot.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

Overview

class Real get_node_statistics request

Instance Attribute Summary

Attributes included from Proxmox::Core

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

Instance Method Summary collapse

Methods included from Proxmox::Core

#credentials, #initialize_identity, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real


120
121
122
123
124
125
126
127
128
# File 'lib/fog/compute/proxmox.rb', line 120

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


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

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

#check_vmid(vmid) ⇒ Object


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

def check_vmid(vmid)
  request(
    expects: [200],
    method: 'GET',
    path: 'cluster/nextid',
    query: "vmid=#{vmid}"
  )
end

#clone_server(path_params, body_params) ⇒ Object


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

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

#create_backup(path_params, body_params) ⇒ Object


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

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

#create_server(path_params, body_params) ⇒ Object


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

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

#create_snapshot(path_params, body_params) ⇒ Object


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

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

#create_spice(path_params, body_params) ⇒ Object


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

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

#create_term(path_params, body_params) ⇒ Object


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

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

#create_vnc(path_params, body_params) ⇒ Object


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

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

#delete_server(path_params, body_params) ⇒ Object


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

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

#delete_snapshot(path_params, query_params) ⇒ Object


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

def delete_snapshot(path_params, query_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  snapname = path_params[:snapname]
  response = request(
    expects: [200],
    method: 'DELETE',
    path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}",
    query: URI.encode_www_form(query_params)
  )
  Fog::Proxmox::Json.get_data(response)
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(node) ⇒ Object


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

def get_node(node)
  response = request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/status"
  )
  Fog::Proxmox::Json.get_data(response)
end

#get_node_statistics(path_params, query_params) ⇒ Object


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

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

#get_server_config(path_params) ⇒ Object


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

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

#get_server_status(path_params) ⇒ Object


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

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

#get_snapshot(path_params) ⇒ Object


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

def get_snapshot(path_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  snapname = path_params[:snapname]
  response = request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}/config"
  )
  Fog::Proxmox::Json.get_data(response)
end

#get_storage(node, storage, options) ⇒ Object


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

def get_storage(node, storage, options)
  response = request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/storage/#{storage}/status",
    query: URI.encode_www_form(options)
  )
  Fog::Proxmox::Json.get_data(response)
end

#get_task(node, upid) ⇒ Object


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

def get_task(node, upid)
  response = request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/tasks/#{upid}"
  )
  Fog::Proxmox::Json.get_data(response)
end

#get_vnc(path_params, query_params) ⇒ Object


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

def get_vnc(path_params, query_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  response = request(
    expects: [101, 200],
    method: 'GET',
    path: "nodes/#{node}/#{type}/#{vmid}/vncwebsocket",
    query: URI.encode_www_form(query_params)
  )
  Fog::Proxmox::Json.get_data(response)
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
33
# File 'lib/fog/compute/proxmox/requests/list_nodes.rb', line 26

def list_nodes
  request(
    expects: [200],
    method: 'GET',
    path: 'cluster/resources',
    query: 'type=node'
  )
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


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

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


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

def log_task(node, upid, options)
  response = request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/tasks/#{upid}/log",
    query: URI.encode_www_form(options)
  )
  Fog::Proxmox::Json.get_data(response)
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


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

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

#move_volume(path_params, body_params) ⇒ Object


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

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

#next_vmidObject


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

def next_vmid
  request(
    expects: [200],
    method: 'GET',
    path: 'cluster/nextid'
  )
end

#resize_container(path_params, body_params) ⇒ Object


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

def resize_container(path_params, body_params)
  node = path_params[:node]
  vmid = path_params[:vmid]
  response = request(
    expects: [200],
    method: 'PUT',
    path: "nodes/#{node}/lxc/#{vmid}/resize",
    body: URI.encode_www_form(body_params)
  )
  Fog::Proxmox::Json.get_data(response)
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


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

def status_task(node, upid)
  response = request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/tasks/#{upid}/status"
  )
  Fog::Proxmox::Json.get_data(response)
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


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

def update_server(path_params, body_params)
  node = path_params[:node]
  type = path_params[:type]
  vmid = path_params[:vmid]
  response = request(
    expects: [200],
    method: type == 'qemu' ? 'POST' : 'PUT',
    path: "nodes/#{node}/#{type}/#{vmid}/config",
    body: URI.encode_www_form(body_params)
  )
  Fog::Proxmox::Json.get_data(response)
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