Class: Uv::Proxmox::VirtualMachine
- Inherits:
-
Object
- Object
- Uv::Proxmox::VirtualMachine
- Includes:
- Blockenspiel::DSL
- Defined in:
- lib/uv_proxmox/virtual_machine.rb
Instance Attribute Summary collapse
-
#operation ⇒ Object
Returns the value of attribute operation.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#operation ⇒ Object
Returns the value of attribute operation.
33 34 35 |
# File 'lib/uv_proxmox/virtual_machine.rb', line 33 def operation @operation end |
Class Method Details
.create(&block) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/uv_proxmox/virtual_machine.rb', line 35 def self.create(&block) @vm = Uv::Proxmox::VirtualMachine.new Blockenspiel.invoke(block, @vm) @vm.operation = 'create' Uv::Proxmox.commands << @vm.to_command end |
.update(&block) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/uv_proxmox/virtual_machine.rb', line 43 def self.update(&block) @vm = Uv::Proxmox::VirtualMachine.new Blockenspiel.invoke(block, @vm) @vm.operation = 'update' Uv::Proxmox.commands << @vm.to_command end |
Instance Method Details
#to_command ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/uv_proxmox/virtual_machine.rb', line 51 def to_command raise ArgumentError, 'missing vmid' if id.blank? raise ArgumentError, 'missing template' if template.blank? and self.operation == 'create' commands = [] commands << "--ostemplate #{template}" unless template.blank? commands << "--mem #{memory}" unless memory.blank? commands << "--swap #{swap}" unless swap.blank? commands << "--disk #{disk}" unless disk.blank? commands << "--cpus #{cpus}" unless cpus.blank? commands << "--cpuunits #{cpu_units}" unless cpu_units.blank? commands << "--onboot #{boot}" unless boot.blank? task = 'vzcreate' if self.operation == 'create' task = 'vzset' if self.operation == 'update' "pvectl #{task} #{id} #{commands.join(" ")}" end |