mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
F #4913: Fix minor bugs in import actions
This commit is contained in:
parent
5370bde6bf
commit
c551674ca9
@ -110,7 +110,7 @@ get '/vcenter/templates' do
|
||||
error 404, error.to_json
|
||||
end
|
||||
|
||||
templates = dc_folder.get_unimported_templates(vcenter_client, tpool, vcenter_client.vim.host)
|
||||
templates = dc_folder.get_unimported_templates(vcenter_client, tpool)
|
||||
|
||||
if templates.nil?
|
||||
msg = "No datacenter found"
|
||||
@ -178,9 +178,9 @@ get '/vcenter/template/:vcenter_ref' do
|
||||
|
||||
if template_copy_ref
|
||||
|
||||
template = VCenterDriver::Template.new_from_ref(template_copy_ref, vi_client)
|
||||
template = VCenterDriver::Template.new_from_ref(template_copy_ref, vcenter_client)
|
||||
|
||||
one_template = VCenterDriver::Template.get_xml_template(template, vc_uuid, vi_client, vcenter_client.vim.host)
|
||||
one_template = VCenterDriver::Template.get_xml_template(template, vc_uuid, vcenter_client, vcenter_client.vim.host)
|
||||
|
||||
if one_template
|
||||
|
||||
@ -220,7 +220,7 @@ get '/vcenter/template/:vcenter_ref' do
|
||||
t[:one] << template_disks
|
||||
|
||||
# Create images or get nics information for template
|
||||
error, template_nics = template.import_vcenter_nics(vc_uuid, npool)
|
||||
error, template_nics = template.import_vcenter_nics(vc_uuid, npool, vcenter_client.vim.host)
|
||||
|
||||
if !error.empty?
|
||||
append = false
|
||||
|
@ -70,8 +70,7 @@ class DatacenterFolder
|
||||
rpools = cluster.get_resource_pool_list.select {|rp| !rp[:name].empty?}
|
||||
|
||||
host_info = {}
|
||||
cluster_name = "[#{vcenter_instance_name} - #{dc_name}] #{ccr['name'].tr(" ", "_")}"
|
||||
host_info[:cluster_name] = cluster_name
|
||||
host_info[:cluster_name] = "[#{vcenter_instance_name}-#{dc_name}]_#{ccr['name']}".tr(" ", "_")
|
||||
host_info[:cluster_ref] = ccr['_ref']
|
||||
host_info[:vcenter_uuid] = vcenter_uuid
|
||||
host_info[:vcenter_version] = vcenter_version
|
||||
@ -114,7 +113,7 @@ class DatacenterFolder
|
||||
hpool)
|
||||
|
||||
if !!one_host
|
||||
one_clusters[:host_id] = one_host['ID']
|
||||
cluster[:host_id] = one_host['ID']
|
||||
one_clusters[dc_name] << cluster
|
||||
end
|
||||
end
|
||||
|
@ -297,7 +297,9 @@ def self.import_templates(con_ops, options)
|
||||
end
|
||||
|
||||
error, template_nics = template.import_vcenter_nics(vc_uuid,
|
||||
npool)
|
||||
npool,
|
||||
options[:vcenter],
|
||||
dc)
|
||||
if error.empty?
|
||||
t[:one] << template_nics
|
||||
else
|
||||
|
@ -294,13 +294,18 @@ class Template
|
||||
return error, disk_info
|
||||
end
|
||||
|
||||
def import_vcenter_nics(vc_uuid, npool)
|
||||
def import_vcenter_nics(vc_uuid, npool, vcenter_instance_name, dc_name=nil)
|
||||
nic_info = ""
|
||||
error = ""
|
||||
|
||||
begin
|
||||
lock #Lock import operation, to avoid concurrent creation of images
|
||||
|
||||
if !dc_name
|
||||
dc = get_dc
|
||||
dc_name = dc.item.name
|
||||
end
|
||||
|
||||
ccr_ref = self["runtime.host.parent._ref"]
|
||||
ccr_name = self["runtime.host.parent.name"]
|
||||
|
||||
@ -334,7 +339,9 @@ class Template
|
||||
nic[:pg_type],
|
||||
ccr_ref,
|
||||
ccr_name,
|
||||
vc_uuid)
|
||||
vc_uuid,
|
||||
vcenter_instance_name,
|
||||
dc_name)
|
||||
|
||||
# By default add an ethernet range to network size 255
|
||||
ar_str = ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user