1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-27 14:03:40 +03:00

F #~: compatible vCenter70 networks fast import (#1003)

Signed-off-by: Carlos Herrera <cherrera@opennebula.io>
This commit is contained in:
Carlos J. Herrera 2021-03-22 05:57:47 -04:00 committed by GitHub
parent cc4a05a3cd
commit f2c45ac4fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 10 deletions

View File

@ -28,6 +28,7 @@ MAX_VCENTER_PASSWORD_LENGTH = 22 #This is the maximum length for a vCenter passw
require 'vcenter_driver'
$importer = nil
$host_id = nil
helpers do
def one_client(client=nil, conf={})
@ -199,6 +200,7 @@ end
get '/vcenter/networks' do
begin
client = one_client
$host_id = params["host"]
new_vcenter_importer("networks", client)
opts = {
:host => params["host"],
@ -216,7 +218,13 @@ end
post '/vcenter/networks' do
begin
$importer.process_import(params["networks"], params["opts"])
opts = params["opts"]
opts[:host] = $host_id
$importer.process_import(
params["networks"],
opts
)
[200, $importer.output.to_json]
rescue Exception => e

View File

@ -584,6 +584,7 @@ module VCenterDriver
vc_network_name
)
network[vc_network_ref][:network_type] = network_type
network[vc_network_ref][:type] = network_type
# end
# Determine if the network must be excluded

View File

@ -500,17 +500,26 @@ module VCenterDriver
one_client = OpenNebula::Client.new
one_host = OpenNebula::Host.new_with_id(opts[:host], one_client)
rc = one_host.info
raise rc.message if OpenNebula.is_error? rc
# Get all networks in vcenter cluster (one_host)
vc_cluster_networks = dc_folder.cluster_networks(one_host)
vc_cluster_networks_map_ref = {}
# Iterate over vcenter networks
vc_cluster_networks.each do |vc_cluster_network|
vc_cluster_networks_map_ref[vc_cluster_network._ref] =
vc_cluster_network
end
indexes.each do |index|
begin
@rollback = []
@info[index] = {}
vc_cluster_network = VCenterDriver::Network.new_from_ref(
index,
@vi_client
)
vc_cluster_network = vc_cluster_network.item
vc_cluster_network = vc_cluster_networks_map_ref[index]
if hpool.respond_to?(:message)
raise 'Could not get OpenNebula HostPool: ' \
@ -526,7 +535,6 @@ module VCenterDriver
params[:_hpool] = hpool
params[:one_host] = one_host
params[:args] = opts
params[:short] = !opts[:short]
selected = dc_folder.process_network(params)
@ -561,8 +569,8 @@ module VCenterDriver
false
)
if npool.respond_to?(:message)
raise "Could not get \
OpenNebula VirtualNetworkPool: #{npool.message}"
raise 'Could not get ' \
"OpenNebula VirtualNetworkPool: #{npool.message}"
end
# Get OpenNebula's host pool