1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

F #4913: The same vCenter cluster can be imported with different resource pool confinements

This commit is contained in:
mcabrerizo 2017-04-18 13:14:58 +02:00
parent e1f51ba73e
commit 1362c8964a
4 changed files with 11 additions and 13 deletions

View File

@ -58,14 +58,6 @@ class DatacenterFolder
host_folder = dc.host_folder
host_folder.fetch_clusters!
host_folder.items.values.each do |ccr|
one_host = VCenterDriver::VIHelper.find_by_ref(OpenNebula::HostPool,
"TEMPLATE/VCENTER_CCR_REF",
ccr['_ref'],
vcenter_uuid,
hpool)
next if one_host #If the host has been already imported
cluster = VCenterDriver::ClusterComputeResource.new_from_ref(ccr['_ref'], @vi_client)
rpools = cluster.get_resource_pool_list.select {|rp| !rp[:name].empty?}

View File

@ -540,7 +540,14 @@ class ClusterComputeResource
one_cluster_id = -1 if !one_cluster_id
rc = one_host.allocate(cluster[:cluster_name], 'vcenter', 'vcenter', one_cluster_id.to_i)
cluster_name = ""
if rp
cluster_name << cluster[:cluster_name] << "_#{rp.tr("/", "_")}"
else
cluster_name << cluster[:cluster_name]
end
rc = one_host.allocate(cluster_name, 'vcenter', 'vcenter', one_cluster_id.to_i)
if OpenNebula.is_error?(rc)
raise "Could not allocate host: #{rc.message}"

View File

@ -7,7 +7,6 @@ class VIClient
attr_accessor :rp
def initialize(opts)
opts = {:insecure => true}.merge(opts)
@vim = RbVmomi::VIM.connect(opts)
@ -21,7 +20,7 @@ class VIClient
rp = opts.delete(:rp)
if rp
rp_list = get_resource_pools(ccr)
rp_ref = rp_list.select { |r| r[:name] == rp }.first._ref rescue nil
rp_ref = rp_list.select { |r| r[:name] == rp }.first[:ref] rescue nil
@rp = RbVmomi::VIM::ResourcePool(@vim, rp_ref) if rp_ref
end
end

View File

@ -896,8 +896,8 @@ class VirtualMachine < Template
req_rp_ref = rp_list.select { |rp| rp[:name] == req_rp }.first[:ref] rescue nil
if vi_client.rp_confined?
if req_rp_ref && req_rp_ref != vi_client.rp
raise "Available resource pool in host [#{vi_client.rp}]"\
if req_rp_ref && req_rp_ref != vi_client.rp._ref
raise "Resource pool [#{vi_client.rp.name}] in host"\
" does not match requested resource pool"\
" [#{req_rp}]"
end