From 995ec0ca7d1f4648f2d4fe178d73b5864dd6d920 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Fri, 14 Jun 2019 13:28:04 +0200 Subject: [PATCH] B #3430: vCenter cache vcenter uuid reference Until now, objects caching depends on the VCENTER_INSTANCE_ID attribute being present in the objects XML. This prevents the correct retrieval if the objects XML is empty. Now the uuid can be passed explicitly. (cherry picked from commit cbe4f7715081311bdd63a26596bf28e196d92f51) --- src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 0461062ccf..1d89fe6347 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb @@ -130,7 +130,7 @@ class VIHelper one_name(the_class, name, key, pool, bytes+2) end - def self.get_ref_key(element, attribute) + def self.get_ref_key(element, attribute, vcenter_uuid = nil) key = element[attribute] tvid = element["TEMPLATE/VCENTER_INSTANCE_ID"] @@ -140,16 +140,18 @@ class VIHelper key += tvid elsif uvid key += uvid + elsif vcenter_uuid + key += vcenter_uuid end return key end - def self.create_ref_hash(attribute, pool) + def self.create_ref_hash(attribute, pool, vcenter_uuid = nil) hash = {} pool.each_element(Proc.new do |e| - refkey = get_ref_key(e, attribute) + refkey = get_ref_key(e, attribute, vcenter_uuid) hash[refkey] = e end) @@ -185,7 +187,9 @@ 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 refkey = ""