mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature 1540 2 (#2909)
* Add hostname_to_moref function * F #1540: Use hostname_to_moref function
This commit is contained in:
parent
9aff8044ef
commit
e95b4ef738
@ -243,9 +243,21 @@ class ClusterComputeResource
|
||||
return rp_info
|
||||
end
|
||||
|
||||
def monitor_host_systems
|
||||
host_info = ""
|
||||
def hostname_to_moref(hostname)
|
||||
result = filter_hosts
|
||||
|
||||
moref = ""
|
||||
result.each do |r|
|
||||
if r.obj.name == hostname
|
||||
moref = r.obj._ref
|
||||
break
|
||||
end
|
||||
end
|
||||
raise "Host #{hostname} was not found" if moref.empty?
|
||||
return moref
|
||||
end
|
||||
|
||||
def filter_hosts
|
||||
view = @vi_client.vim.serviceContent.viewManager.CreateContainerView({
|
||||
container: @item, #View for Hosts inside this cluster
|
||||
type: ['HostSystem'],
|
||||
@ -284,7 +296,13 @@ class ClusterComputeResource
|
||||
)
|
||||
|
||||
result = pc.RetrieveProperties(:specSet => [filterSpec])
|
||||
view.DestroyView # Destroy the view
|
||||
return result
|
||||
end
|
||||
|
||||
def monitor_host_systems
|
||||
host_info = ""
|
||||
result = filter_hosts
|
||||
hosts = {}
|
||||
result.each do |r|
|
||||
hashed_properties = r.to_hash
|
||||
@ -319,8 +337,6 @@ class ClusterComputeResource
|
||||
host_info << "]"
|
||||
end
|
||||
|
||||
view.DestroyView # Destroy the view
|
||||
|
||||
return host_info
|
||||
end
|
||||
|
||||
|
@ -2418,7 +2418,8 @@ class VirtualMachine < VCenterDriver::Template
|
||||
|
||||
begin
|
||||
# retrieve host from DRS
|
||||
resourcepool = config[:cluster].resourcePool
|
||||
one_cluster = config[:cluster]
|
||||
resourcepool = one_cluster.item.resourcePool
|
||||
datastore = config[:datastore]
|
||||
|
||||
if datastore
|
||||
@ -2429,10 +2430,12 @@ class VirtualMachine < VCenterDriver::Template
|
||||
|
||||
if config[:esx_migration_list].is_a?(String)
|
||||
if config[:esx_migration_list]==""
|
||||
relocate_spec_params[:host] = config[:cluster].host.sample
|
||||
relocate_spec_params[:host] = config[:cluster].item.host.sample
|
||||
elsif config[:esx_migration_list]!="Selected_by_DRS"
|
||||
hosts = config[:esx_migration_list].split(' ')
|
||||
relocate_spec_params[:host] = hosts.sample
|
||||
hostnames = config[:esx_migration_list].split(' ')
|
||||
hostname = hostnames.sample
|
||||
host_moref = one_cluster.hostname_to_moref(hostname)
|
||||
relocate_spec_params[:host] = host_moref
|
||||
end
|
||||
end
|
||||
|
||||
@ -2933,7 +2936,7 @@ class VirtualMachine < VCenterDriver::Template
|
||||
raise 'datastore migration from poweroff state with managed disks is not supported' if error
|
||||
|
||||
ccr_ref = dst_host['/HOST/TEMPLATE/VCENTER_CCR_REF']
|
||||
vc_host = VCenterDriver::ClusterComputeResource.new_from_ref(ccr_ref, vi_client).item
|
||||
vc_host = VCenterDriver::ClusterComputeResource.new_from_ref(ccr_ref, vi_client)
|
||||
|
||||
config = { :cluster => vc_host }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user