mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
B #5371: Don't use OPENNEBULA_MANAGED=NO for the networks
This commit is contained in:
parent
011da01431
commit
a56db4971e
@ -77,18 +77,8 @@ class Network
|
|||||||
|
|
||||||
one_tmp = {}
|
one_tmp = {}
|
||||||
|
|
||||||
if unmanaged
|
if unmanaged && unmanaged == "wild"
|
||||||
if unmanaged == "wild"
|
network_import_name = "#{network_name} [VM #{vm_or_template_name}]"
|
||||||
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
|
|
||||||
else
|
else
|
||||||
hash_name = "#{network_name} - #{ccr_name.tr(" ", "_")} [#{vcenter_instance_name} - #{dc_name}]_#{cluster_location}"
|
hash_name = "#{network_name} - #{ccr_name.tr(" ", "_")} [#{vcenter_instance_name} - #{dc_name}]_#{cluster_location}"
|
||||||
sha256 = Digest::SHA256.new
|
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}"
|
network_import_name = "#{network_name} - #{ccr_name.tr(" ", "_")} [#{vcenter_instance_name} - #{dc_name}]_#{network_hash}"
|
||||||
end
|
end
|
||||||
|
|
||||||
one_tmp[:name] = network_name
|
one_tmp[:name] = network_name
|
||||||
one_tmp[:import_name] = network_import_name
|
one_tmp[:import_name] = network_import_name
|
||||||
one_tmp[:bridge] = network_name
|
one_tmp[:bridge] = network_name
|
||||||
one_tmp[:type] = network_type
|
one_tmp[:type] = network_type
|
||||||
one_tmp[:cluster] = ccr_name
|
one_tmp[:cluster] = ccr_name
|
||||||
one_tmp[:cluster_location] = cluster_location
|
one_tmp[:cluster_location] = cluster_location
|
||||||
one_tmp[:vcenter_ccr_ref] = ccr_ref
|
one_tmp[:vcenter_ccr_ref] = ccr_ref
|
||||||
one_tmp[:one_cluster_id] = cluster_id
|
one_tmp[:one_cluster_id] = cluster_id
|
||||||
|
|
||||||
one_tmp[:one] = to_one(network_import_name, network_name, network_ref, network_type,
|
one_tmp[:one] = to_one(network_import_name, network_name, network_ref, network_type,
|
||||||
ccr_ref, vcenter_uuid, unmanaged, template_ref, dc_ref)
|
ccr_ref, vcenter_uuid, unmanaged, template_ref, dc_ref)
|
||||||
return one_tmp
|
return one_tmp
|
||||||
@ -121,7 +112,6 @@ class Network
|
|||||||
|
|
||||||
template += "VCENTER_CCR_REF=\"#{ccr_ref}\"\n" if !unmanaged
|
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
|
template += "VCENTER_TEMPLATE_REF=\"#{template_ref}\"\n" if template_ref
|
||||||
|
|
||||||
return template
|
return template
|
||||||
@ -135,22 +125,6 @@ class Network
|
|||||||
end
|
end
|
||||||
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)
|
def self.remove_net_ref(network_id)
|
||||||
one_vnet = VCenterDriver::VIHelper.one_item(OpenNebula::VirtualNetwork, network_id)
|
one_vnet = VCenterDriver::VIHelper.one_item(OpenNebula::VirtualNetwork, network_id)
|
||||||
one_vnet.info
|
one_vnet.info
|
||||||
|
@ -361,9 +361,12 @@ class Template
|
|||||||
|
|
||||||
vc_nics.each do |nic|
|
vc_nics.each do |nic|
|
||||||
# Check if the network already exists
|
# Check if the network already exists
|
||||||
network_found = VCenterDriver::Network.get_unmanaged_vnet_by_ref(nic[:net_ref],
|
network_found = VCenterDriver::VIHelper.find_by_ref(OpenNebula::VirtualNetworkPool,
|
||||||
vc_uuid,
|
"TEMPLATE/VCENTER_NET_REF",
|
||||||
npool)
|
nic[:net_ref],
|
||||||
|
vc_uuid,
|
||||||
|
npool)
|
||||||
|
|
||||||
#Network is already in OpenNebula
|
#Network is already in OpenNebula
|
||||||
if network_found
|
if network_found
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user