B #5286: imported vnet real hash names (#542)

* B #5286: imported networks from templates are 'properly' hashed

* B #5286: imported wilds have the real vnet name
This commit is contained in:
Sergio Semedi Barranco authored and Tino Vázquez committed 2017-10-27 15:22:37 +02:00
1 parent 121331bc7e
commit 82c8fcbf97
3 files changed
+23 -9

No files matched your search

@@ -100,14 +100,10 @@ class Network
one_tmp = {}
if unmanaged && unmanaged == "wild"
network_import_name = "#{network_name} [VM #{vm_or_template_name}]"
else
hash_name = "#{network_name} - #{ccr_name.tr(" ", "_")} [#{vcenter_instance_name} - #{dc_name}]_#{cluster_location}"
sha256 = Digest::SHA256.new
network_hash = sha256.hexdigest(hash_name)[0..11]
network_import_name = "#{network_name} - #{ccr_name.tr(" ", "_")} [#{vcenter_instance_name} - #{dc_name}]_#{network_hash}"
end
hash_name = "#{network_name} - #{ccr_name.tr(" ", "_")} [#{vcenter_instance_name} - #{dc_name}]_#{cluster_location}"
sha256 = Digest::SHA256.new
network_hash = sha256.hexdigest(hash_name)[0..11]
network_import_name = "#{network_name} - #{ccr_name.tr(" ", "_")} [#{vcenter_instance_name} - #{dc_name}]_#{network_hash}"
one_tmp[:name] = network_name
one_tmp[:import_name] = network_import_name
@@ -157,6 +157,21 @@ class VIHelper
end
end
def self.get_location(item)
folders = []
while !item.instance_of? RbVmomi::VIM::Datacenter
item = item.parent
if !item.instance_of? RbVmomi::VIM::Datacenter
folders << item.name if item.name != "host"
end
raise "Could not find the location" if item.nil?
end
location = folders.reverse.join("/")
location = "/" if location.empty?
return location
end
end # class VIHelper
end # module VCenterDriver
@@ -437,6 +437,9 @@ class Template
ar_size = 255
end
net_host = VCenterDriver::ClusterComputeResource.new_from_ref(ccr_ref, @vi_client)
location = VCenterDriver::VIHelper.get_location(net_host.item)
# Prepare the Virtual Network template
one_vnet = VCenterDriver::Network.to_one_template(nic[:net_name],
nic[:net_ref],
@@ -447,7 +450,7 @@ class Template
vcenter_instance_name,
dc_name,
cluster_id,
nil,
location,
unmanaged,
template_ref,
dc_ref,