Add VM poll action

This commit is contained in:
mcabrerizo committed 2017-02-14 17:18:42 +01:00
1 parent d8463f14d7
commit 74d473798f
1 file changed
+16 -10
+16 -10
View File
@@ -28,17 +28,23 @@ end
$: << RUBY_LIB_LOCATION
$: << File.dirname(__FILE__)
require 'vcenter_driver'
require 'vcenter_driver2'
deploy_id = ARGV[0]
host = ARGV[1]
vm_ref = ARGV[0]
vc_cluster_name = ARGV[1]
host_id = VCenterDriver::VIClient.translate_hostname(host)
vi_client = VCenterDriver::VIClient.new host_id
host = VCenterDriver::VCenterHost.new vi_client
vm = vi_client.find_vm_template(deploy_id)
vm = VCenterDriver::VCenterVm.new(vi_client, vm)
begin
vm.monitor(host)
vi_client = VCenterDriver::VIClient.new_from_hostname(vc_cluster_name)
puts vm.info
vm = VCenterDriver::VirtualMachine.new_from_ref(vi_client, vm_ref)
vm.monitor
puts vm.info
rescue Exception => e
STDERR.puts "Cannot poll info for VM #{vm_ref} on vCenter cluster "\
"#{vc_cluster_name} failed due to \"#{e.message}\""
exit(-1)
end