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 and deleting the disk files.
- #guest_info ⇒ Object
-
#ip_address ⇒ Object
Shortcut to GuestInfo.ip_address.
- #nics ⇒ Object
-
#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’.
- #reset ⇒ Object
Instance Attribute Details
#cpus ⇒ Object
Returns the value of attribute cpus.
420 421 422 |
# File 'lib/esx.rb', line 420 def cpus @cpus end |
#ethernet_cards_number ⇒ Object
Returns the value of attribute ethernet_cards_number.
420 421 422 |
# File 'lib/esx.rb', line 420 def ethernet_cards_number @ethernet_cards_number end |
#memory_size ⇒ Object
Returns the value of attribute memory_size.
420 421 422 |
# File 'lib/esx.rb', line 420 def memory_size @memory_size end |
#name ⇒ Object
Returns the value of attribute name.
421 422 423 |
# File 'lib/esx.rb', line 421 def name @name end |
#virtual_disks_number ⇒ Object
Returns the value of attribute virtual_disks_number.
421 422 423 |
# File 'lib/esx.rb', line 421 def virtual_disks_number @virtual_disks_number end |
#vm_object ⇒ Object
Returns the value of attribute vm_object.
421 422 423 |
# File 'lib/esx.rb', line 421 def vm_object @vm_object end |
Class Method Details
.wrap(vm) ⇒ Object
Wraps a RbVmomi::VirtualMachine object
**This method should never be called manually.**
427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/esx.rb', line 427 def self.wrap(vm) _vm = VM.new _vm.name = vm.name ## HACK: for some reason vm.summary.config.memorySizeMB returns nil # under some conditions _vm.memory_size = vm.summary.config.memorySizeMB*1024*1024 rescue 0 _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 and deleting the disk files
459 460 461 462 |
# File 'lib/esx.rb', line 459 def destroy #disks = vm_object.config.hardware.device.grep(RbVmomi::VIM::VirtualDisk) vm_object.Destroy_Task.wait_for_completion end |
#guest_info ⇒ Object
468 469 470 |
# File 'lib/esx.rb', line 468 def guest_info GuestInfo.wrap(vm_object.guest) end |
#ip_address ⇒ Object
Shortcut to GuestInfo.ip_address
475 476 477 |
# File 'lib/esx.rb', line 475 def ip_address guest_info.ip_address end |
#nics ⇒ Object
479 480 481 482 483 484 485 |
# File 'lib/esx.rb', line 479 def nics list = [] vm_object.config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).each do |n| list << NetworkInterface.wrap(n) end list end |
#power_off ⇒ Object
Power Off a VM
453 454 455 |
# File 'lib/esx.rb', line 453 def power_off vm_object.PowerOffVM_Task.wait_for_completion end |
#power_on ⇒ Object
Power On a VM
448 449 450 |
# File 'lib/esx.rb', line 448 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’
443 444 445 |
# File 'lib/esx.rb', line 443 def power_state vm_object.summary.runtime.powerState end |
#reset ⇒ Object
464 465 466 |
# File 'lib/esx.rb', line 464 def reset vm_object.ResetVM_Task.wait_for_completion end |