Class: ESX::VM
- Inherits:
-
Object
- Object
- ESX::VM
- Defined in:
- lib/esx.rb
Instance Attribute Summary collapse
-
#cpus ⇒ Object
Returns the value of attribute cpus.
-
#ethernet_cards_number ⇒ Object
Returns the value of attribute ethernet_cards_number.
-
#memory_size ⇒ Object
Returns the value of attribute memory_size.
-
#name ⇒ Object
Returns the value of attribute name.
-
#virtual_disks_number ⇒ Object
Returns the value of attribute virtual_disks_number.
-
#vm_object ⇒ Object
Returns the value of attribute vm_object.
Class Method Summary collapse
-
.wrap(vm) ⇒ Object
Wraps a RbVmomi::VirtualMachine object.
Instance Method Summary collapse
-
#destroy ⇒ Object
Destroy the VirtualMaching removing it from the inventory.
- #guest_info ⇒ Object
-
#ip_address ⇒ Object
Shortcut to GuestInfo.ip_address.
-
#power_off ⇒ Object
Power Off a VM.
-
#power_on ⇒ Object
Power On a VM.
-
#power_state ⇒ Object
Returns the state of the VM as a string ‘poweredOff’, ‘poweredOn’.
Instance Attribute Details
#cpus ⇒ Object
Returns the value of attribute cpus.
274 275 276 |
# File 'lib/esx.rb', line 274 def cpus @cpus end |
#ethernet_cards_number ⇒ Object
Returns the value of attribute ethernet_cards_number.
274 275 276 |
# File 'lib/esx.rb', line 274 def ethernet_cards_number @ethernet_cards_number end |
#memory_size ⇒ Object
Returns the value of attribute memory_size.
274 275 276 |
# File 'lib/esx.rb', line 274 def memory_size @memory_size end |
#name ⇒ Object
Returns the value of attribute name.
275 276 277 |
# File 'lib/esx.rb', line 275 def name @name end |
#virtual_disks_number ⇒ Object
Returns the value of attribute virtual_disks_number.
275 276 277 |
# File 'lib/esx.rb', line 275 def virtual_disks_number @virtual_disks_number end |
#vm_object ⇒ Object
Returns the value of attribute vm_object.
275 276 277 |
# File 'lib/esx.rb', line 275 def vm_object @vm_object end |
Class Method Details
.wrap(vm) ⇒ Object
Wraps a RbVmomi::VirtualMachine object
**This method should never be called manually.**
281 282 283 284 285 286 287 288 289 290 |
# File 'lib/esx.rb', line 281 def self.wrap(vm) _vm = VM.new _vm.name = vm.name _vm.memory_size = vm.summary.config.memorySizeMB.megabytes.to.bytes _vm.cpus = vm.summary.config.numCpu _vm.ethernet_cards_number = vm.summary.config.numEthernetCards _vm.virtual_disks_number = vm.summary.config.numVirtualDisks _vm.vm_object = vm _vm end |
Instance Method Details
#destroy ⇒ Object
Destroy the VirtualMaching removing it from the inventory
This operation does not destroy VM disks
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/esx.rb', line 313 def destroy disks = vm_object.config.hardware.device.grep(RbVmomi::VIM::VirtualDisk) #disks.select { |x| x.backing.parent == nil }.each do |disk| # spec = { # :deviceChange => [ # { # :operation => :remove, # :device => disk # } # ] # } # vm_object.ReconfigVM_Task(:spec => spec).wait_for_completion #end vm_object.Destroy_Task.wait_for_completion end |
#guest_info ⇒ Object
329 330 331 |
# File 'lib/esx.rb', line 329 def guest_info GuestInfo.wrap(vm_object.guest) end |
#ip_address ⇒ Object
Shortcut to GuestInfo.ip_address
336 337 338 |
# File 'lib/esx.rb', line 336 def ip_address guest_info.ip_address end |
#power_off ⇒ Object
Power Off a VM
305 306 307 |
# File 'lib/esx.rb', line 305 def power_off vm_object.PowerOffVM_Task.wait_for_completion end |
#power_on ⇒ Object
Power On a VM
300 301 302 |
# File 'lib/esx.rb', line 300 def power_on vm_object.PowerOnVM_Task.wait_for_completion end |
#power_state ⇒ Object
Returns the state of the VM as a string ‘poweredOff’, ‘poweredOn’
295 296 297 |
# File 'lib/esx.rb', line 295 def power_state vm_object.summary.runtime.powerState end |