1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Grooming to vCenter IM

Error handling + more efficient host retrieval
This commit is contained in:
Tino Vazquez 2018-02-19 19:40:45 +01:00
parent bce2bf8c18
commit ec517d0fc5
2 changed files with 18 additions and 8 deletions

View File

@ -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!

View File

@ -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