mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
* B #5286: imported networks from templates are 'properly' hashed
* B #5286: imported wilds have the real vnet name
(cherry picked from commit 82c8fcbf97
)
This commit is contained in:
parent
49c21df31e
commit
0466a376c3
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user