From 5baf68b4e97d2fe311443b7d3c1883fe8de78dfb Mon Sep 17 00:00:00 2001 From: Sergio Semedi Barranco Date: Thu, 18 Jan 2018 18:10:54 +0100 Subject: [PATCH] B #1654: find_by_ref fix (#1655) --- src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb b/src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb index 5ff25a2c7f..e4505ddb6e 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb @@ -55,10 +55,13 @@ class VIHelper end end - def self.create_ref_hash(attribute, pool) + def self.create_ref_hash(attribute, pool, vcenter_uuid) hash = {} pool.each_element(Proc.new do |e| + vcenter_instance_id = e["TEMPLATE/VCENTER_INSTANCE_ID"] || e["USER_TEMPLATE/VCENTER_INSTANCE_ID"] + next if vcenter_uuid != vcenter_instance_id + ref = e[attribute] hash[ref] = { opennebula_object: e, @@ -85,7 +88,7 @@ class VIHelper @ref_hash ||= {} if @ref_hash[attribute].nil? || @ref_hash[attribute] == {} - @ref_hash[attribute] = create_ref_hash(attribute, pool) + @ref_hash[attribute] = create_ref_hash(attribute, pool, vcenter_uuid) end e = @ref_hash[attribute][ref]