1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

B #5371: Don't use OPENNEBULA_MANAGED=NO for the networks

This commit is contained in:
Jaime Melis 2017-09-15 19:06:19 +02:00
parent 011da01431
commit a56db4971e
2 changed files with 16 additions and 39 deletions

View File

@ -77,18 +77,8 @@ class Network
one_tmp = {}
if unmanaged
if unmanaged == "wild"
network_import_name = "#{network_name} [VM #{vm_or_template_name}]"
end
if unmanaged == "template"
hash_name = "#{network_ref}#{vcenter_uuid}"
sha256 = Digest::SHA256.new
network_hash = sha256.hexdigest(hash_name)[0..11]
network_import_name = "#{network_name} - #{network_hash}"
end
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
@ -96,14 +86,15 @@ class Network
network_import_name = "#{network_name} - #{ccr_name.tr(" ", "_")} [#{vcenter_instance_name} - #{dc_name}]_#{network_hash}"
end
one_tmp[:name] = network_name
one_tmp[:import_name] = network_import_name
one_tmp[:bridge] = network_name
one_tmp[:type] = network_type
one_tmp[:cluster] = ccr_name
one_tmp[:name] = network_name
one_tmp[:import_name] = network_import_name
one_tmp[:bridge] = network_name
one_tmp[:type] = network_type
one_tmp[:cluster] = ccr_name
one_tmp[:cluster_location] = cluster_location
one_tmp[:vcenter_ccr_ref] = ccr_ref
one_tmp[:one_cluster_id] = cluster_id
one_tmp[:vcenter_ccr_ref] = ccr_ref
one_tmp[:one_cluster_id] = cluster_id
one_tmp[:one] = to_one(network_import_name, network_name, network_ref, network_type,
ccr_ref, vcenter_uuid, unmanaged, template_ref, dc_ref)
return one_tmp
@ -121,7 +112,6 @@ class Network
template += "VCENTER_CCR_REF=\"#{ccr_ref}\"\n" if !unmanaged
template += "OPENNEBULA_MANAGED=\"NO\"\n" if unmanaged
template += "VCENTER_TEMPLATE_REF=\"#{template_ref}\"\n" if template_ref
return template
@ -135,22 +125,6 @@ class Network
end
end
def self.get_unmanaged_vnet_by_ref(ref, vcenter_uuid, pool = nil)
if pool.nil?
pool = VCenterDriver::VIHelper.one_pool(OpenNebula::VirtualNetworkPool, false)
if pool.respond_to?(:message)
raise "Could not get OpenNebula VirtualNetworkPool: #{pool.message}"
end
end
element = pool.select do |e|
e["TEMPLATE/VCENTER_NET_REF"] == ref &&
e["TEMPLATE/VCENTER_INSTANCE_ID"] == vcenter_uuid &&
e["TEMPLATE/OPENNEBULA_MANAGED"] == "NO"
end.first rescue nil
return element
end
def self.remove_net_ref(network_id)
one_vnet = VCenterDriver::VIHelper.one_item(OpenNebula::VirtualNetwork, network_id)
one_vnet.info

View File

@ -361,9 +361,12 @@ class Template
vc_nics.each do |nic|
# Check if the network already exists
network_found = VCenterDriver::Network.get_unmanaged_vnet_by_ref(nic[:net_ref],
vc_uuid,
npool)
network_found = VCenterDriver::VIHelper.find_by_ref(OpenNebula::VirtualNetworkPool,
"TEMPLATE/VCENTER_NET_REF",
nic[:net_ref],
vc_uuid,
npool)
#Network is already in OpenNebula
if network_found