Class: CFCM::IAAS::Vsphere
- Inherits:
-
Object
- Object
- CFCM::IAAS::Vsphere
- Defined in:
- lib/cfcm/iaas/vsphere.rb
Instance Method Summary collapse
-
#initialize(host, user, password, config) ⇒ Vsphere
constructor
A new instance of Vsphere.
- #power_off_vm(vm_name) ⇒ Object
Constructor Details
#initialize(host, user, password, config) ⇒ Vsphere
Returns a new instance of Vsphere.
7 8 9 10 11 12 |
# File 'lib/cfcm/iaas/vsphere.rb', line 7 def initialize(host, user, password, config) @host = host @user = user @password = password @config = config end |
Instance Method Details
#power_off_vm(vm_name) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/cfcm/iaas/vsphere.rb', line 14 def power_off_vm(vm_name) opts = {:host=>@host, :user=>@user, :password=>@password, :insecure=>true} vim = RbVmomi::VIM.connect opts dc = vim.serviceInstance.content.rootFolder.traverse(@config["datacenter"], RbVmomi::VIM::Datacenter) or abort "datacenter not found" vm = dc.vmFolder.traverse(vm_name, RbVmomi::VIM::VirtualMachine) or abort "VM not found" vm.PowerOffVM_Task.wait_for_completion end |