B #1759: Change vCenter cache index

Now uses moref + vCenter instance uuid
This commit is contained in:
Tino Vazquez committed 2018-02-19 11:34:53 +01:00
1 parent ee3abcaa52
commit 06443130a2
1 file changed
+23 -3
@@ -55,12 +55,28 @@ class VIHelper
end
end
def self.get_ref_key(element, attribute)
key = element[attribute]
tvid = element["TEMPLATE/VCENTER_INSTANCE_ID"]
uvid = element["USER_TEMPLATE/VCENTER_INSTANCE_ID"]
if tvid
key += tvid
elsif uvid
key += uvid
end
return key
end
def self.create_ref_hash(attribute, pool)
hash = {}
pool.each_element(Proc.new do |e|
ref = e[attribute]
hash[ref] = {
refkey = get_ref_key(e, attribute)
hash[refkey] = {
opennebula_object: e,
opennebula_managed: e["TEMPLATE/OPENNEBULA_MANAGED"],
tvcenter_instance_id: e["TEMPLATE/VCENTER_INSTANCE_ID"],
@@ -88,7 +104,11 @@ class VIHelper
@ref_hash[attribute] = create_ref_hash(attribute, pool)
end
e = @ref_hash[attribute][ref]
refkey = ""
refkey = ref if ref
refkey += vcenter_uuid if vcenter_uuid
e = @ref_hash[attribute][refkey]
return nil if e.nil?