Class: Fog::Compute::Proxmox::Container

Inherits:
Server
  • Object
show all
Defined in:
lib/fog/compute/proxmox/models/container.rb

Overview

Container model

Instance Method Summary collapse

Methods inherited from Server

#attach, #backup, #backups, #clone, #connect_vnc, #create, #destroy, #images, #initialize, #list, #migrate, #ready?, #reload, #request, #snapshots, #start_console, #tasks, #template, #type

Constructor Details

This class inherits a constructor from Fog::Compute::Proxmox::Server

Instance Method Details

#action(action, options = {}) ⇒ Object

Raises:

  • (Fog::Errors::Error)

79
80
81
82
# File 'lib/fog/compute/proxmox/models/container.rb', line 79

def action(action, options = {})
  raise Fog::Errors::Error, "Action #{action} not implemented" unless %w[start stop shutdown].include? action
  super
end

#configObject


61
62
63
64
65
# File 'lib/fog/compute/proxmox/models/container.rb', line 61

def config
  path_params = { node: node, type: type, vmid: vmid }
  set_config(service.get_server_config(path_params)) if uptime
  @config
end

#detach(mpid) ⇒ Object


67
68
69
# File 'lib/fog/compute/proxmox/models/container.rb', line 67

def detach(mpid)
  update(delete: mpid)
end

#extend(disk, size, options = {}) ⇒ Object


71
72
73
74
75
76
77
# File 'lib/fog/compute/proxmox/models/container.rb', line 71

def extend(disk, size, options = {})
  requires :vmid, :node
  path_params = { node: node, vmid: vmid }
  body_params = options.merge(disk: disk, size: size)
  task_upid = service.resize_container(path_params, body_params)
  tasks.wait_for(task_upid)
end

#move(volume, storage, options = {}) ⇒ Object


42
43
44
45
46
47
48
# File 'lib/fog/compute/proxmox/models/container.rb', line 42

def move(volume, storage, options = {})
  requires :vmid, :node
  path_params = { node: node, vmid: vmid }
  body_params = options.merge(volume: volume, storage: storage)
  task_upid = service.move_volume(path_params, body_params)
  tasks.wait_for(task_upid)
end

#restore(backup, options = {}) ⇒ Object


34
35
36
37
38
39
40
# File 'lib/fog/compute/proxmox/models/container.rb', line 34

def restore(backup, options = {})
  requires :node, :vmid
  path_params = { node: node, type: type }
  body_params = options.merge(vmid: vmid, ostemplate: backup.volid, force: 1, restore: 1)
  task_upid = service.create_server(path_params, body_params)
  tasks.wait_for(task_upid)
end

#set_config(attributes = {}) ⇒ Object


57
58
59
# File 'lib/fog/compute/proxmox/models/container.rb', line 57

def set_config(attributes = {})
  @config = Fog::Compute::Proxmox::ContainerConfig.new({ service: service, vmid: vmid }.merge(attributes))
end

#update(config = {}) ⇒ Object


50
51
52
53
54
55
# File 'lib/fog/compute/proxmox/models/container.rb', line 50

def update(config = {})
  requires :node, :vmid
  path_params = { node: node, type: type, vmid: vmid }
  body_params = config
  service.update_server(path_params, body_params)
end