From ec517d0fc529d4f57bc797ed5cc970990bcdae76 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 19 Feb 2018 19:40:45 +0100 Subject: [PATCH] Grooming to vCenter IM Error handling + more efficient host retrieval --- src/im_mad/remotes/vcenter.d/poll | 12 ++++++++++-- src/vmm_mad/remotes/lib/vcenter_driver/host.rb | 14 ++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/im_mad/remotes/vcenter.d/poll b/src/im_mad/remotes/vcenter.d/poll index 2fff6ecebf..b4ad6037aa 100755 --- a/src/im_mad/remotes/vcenter.d/poll +++ b/src/im_mad/remotes/vcenter.d/poll @@ -52,7 +52,8 @@ begin puts cluster.monitor puts cluster.monitor_host_systems - vm_monitor_info, last_perf_poll = cluster.monitor_vms + # Print VM monitor info + vm_monitor_info, last_perf_poll = cluster.monitor_vms(host_id) if !vm_monitor_info.empty? puts "VM_POLL=YES" puts vm_monitor_info @@ -61,8 +62,15 @@ begin # Print last VM poll for perfmanager tracking puts "VCENTER_LAST_PERF_POLL=" << last_perf_poll << "\n" if last_perf_poll - puts cluster.monitor_customizations + # Retrieve customizations + begin + puts cluster.monitor_customizations + rescue + # Do not break monitoring on customization error + puts "ERROR=\"Customizations couldn't be retrieved, please check permissions\"" + end + # Print Datastore information dc = cluster.get_dc ds_folder = dc.datastore_folder ds_folder.fetch! diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/host.rb b/src/vmm_mad/remotes/lib/vcenter_driver/host.rb index 8003caf7f0..cdac561e04 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/host.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/host.rb @@ -308,18 +308,20 @@ class ClusterComputeResource return host_info end - def monitor_vms + def monitor_vms(host_id) vc_uuid = @vi_client.vim.serviceContent.about.instanceUuid cluster_name = self["name"] cluster_ref = self["_ref"] # Get info of the host where the VM/template is located - host_id = nil - one_host = VCenterDriver::VIHelper.find_by_ref(OpenNebula::HostPool, - "TEMPLATE/VCENTER_CCR_REF", - cluster_ref, - vc_uuid) + one_host = VCenterDriver::VIHelper.one_item(OpenNebula::Host, host_id) + if !one_host + STDERR.puts "Failed to retieve host with id #{host.id}" + STDERR.puts e.inspect + STDERR.puts e.backtrace + end + host_id = one_host["ID"] if one_host