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

F #4302: Fix error when return is empty (#4675)

* Change get id way
* Fix error when return is empty

Co-authored-by: mouyaq <amoya@opennebula.io>
This commit is contained in:
Angel Luis Moya Gonzalez 2020-05-07 15:02:10 +02:00 committed by GitHub
parent 7e6091f6c5
commit a224d86373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -949,21 +949,16 @@ class VcenterMonitor
view.DestroyView # Destroy the view
# # Get one vms from database
# one_vms = @db.select_one_vms
one_vms = @db.select_one_vms
vms = []
vms_hash.each do |vm_ref, info|
next if info['name'].match(/^one-(\d*)(-(.*))?$/)
one_uuid = "#{vm_ref}#{@vc_uuid}"
vm = VCenterDriver::VirtualMachine.new_from_ref(@vi_client,
vm_ref,
info['name'],
opts)
one_id = vm.vm_id
vm = { :uuid => one_uuid,
:id => one_id,
:id => one_id(one_uuid, one_vms),
:name => "#{info['name']} - #{@cluster.item.name}",
:deploy_id => vm_ref,
:state => vm_state(info['summary.runtime.powerState']),
@ -1174,7 +1169,7 @@ class InstanceCache
raise "There is more than one CCR_REF for host_id = #{host_id}" \
if result.length > 1
result[0][0]
result.empty? ? nil : result[0][0]
end
def select_one_vms