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..286065273c 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb @@ -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?