1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

F #4302: Change wild detecion method and fix resource pool names (#4708)

* Change Wilds detection to old method
* Fix error detecting resource pool name
* Re-dded disk info to vm monitoring

Co-authored-by: mouyaq <amoya@opennebula.io>
Co-authored-by: Tino Vázquez <cvazquez@opennebula.systems>
This commit is contained in:
Angel Luis Moya Gonzalez 2020-05-12 15:17:49 +02:00 committed by GitHub
parent 63a24d3796
commit d7af2a9a86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 18 deletions

View File

@ -243,7 +243,7 @@ class VcenterMonitor
mem_shares_level = info['config.memoryAllocation.shares.level']
mem_shares = info['config.memoryAllocation.shares.shares']
rp_name = rp_list.select {|item| item[:ref] == ref }.first[:name] \
rp_name = @rp_list.select {|item| item[:ref] == ref }.first[:name] \
rescue ''
rp_name = 'Resources' if rp_name.empty?
@ -1044,8 +1044,11 @@ class VcenterMonitor
one_vms
end
def monitor_vms
str_info, last_mon_time = @cluster.monitor_vms(@host_id)
# Return string info for different vm types:
# 'wilds' : VMs in vCenter but not in OpenNebula
# 'ones' : VMs in OpenNebula
def monitor_vms(vm_type)
str_info, last_mon_time = @cluster.monitor_vms(@host_id, vm_type)
return str_info
end

View File

@ -59,7 +59,7 @@ begin
vcm.retrieve_vms_data
# VM wilds info
puts vcm.wilds
puts vcm.monitor_vms('wilds')
# Datastore Monitoring
puts vcm.monitor_datastores

View File

@ -39,10 +39,7 @@ host = ARGV[-1]
host_id = ARGV[-2]
vcm = VcenterMonitor.new(host, host_id)
begin
# Fetch VMs info ( update cache if neccesary )
# vcm.retrieve_vms_data
# puts vcm.probe_vm_monitor
puts vcm.monitor_vms
puts vcm.monitor_vms('ones')
rescue StandardError => e
OpenNebula.handle_driver_exception('im probe_vm_monitor', e, host)
end

View File

@ -502,7 +502,7 @@ class ClusterComputeResource
return host_info
end
def monitor_vms(host_id)
def monitor_vms(host_id, vm_type)
vc_uuid = @vi_client.vim.serviceContent.about.instanceUuid
cluster_name = self["name"]
cluster_ref = self["_ref"]
@ -660,7 +660,13 @@ class ClusterComputeResource
vm = VCenterDriver::VirtualMachine.new_from_ref(@vi_client, vm_ref, info["name"], opts)
id = vm.vm_id
next if id == -1
if vm_type == 'ones'
next if id == -1
elsif vm_type == 'wilds'
next if id != -1
else
next
end
#skip if it's already monitored
if vm.one_exist?

View File

@ -422,10 +422,6 @@ module VirtualMachineMonitor
end
if @vm_info
# rp_name = @vm_info[:rp_list]
# .select {|item|
# item[:ref] == @vm_info['resourcePool']._ref
# }.first[:name] rescue ''
rp_name = @vm_info[:rp_list]
.select do |item|
item[:ref] == @vm_info['resourcePool']._ref
@ -467,10 +463,10 @@ module VirtualMachineMonitor
<< vmtools_verst << "\n"
str_info << 'VCENTER_RP_NAME="' << rp_name << '" ' << "\n"
# @vm.info_disks.each do |disk|
# str_info << "DISK_#{disk[0]}_ACTUAL_PATH=\"[" <<
# disk[1].ds.name << '] ' << disk[1].path << '" '
# end
info_disks.each do |disk|
str_info << "DISK_#{disk[0]}_ACTUAL_PATH=\"[" <<
disk[1].ds.name << '] ' << disk[1].path << '" '
end
str_info
end