diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/host.rb b/src/vmm_mad/remotes/lib/vcenter_driver/host.rb index fe25ff470b..afba5df09c 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/host.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/host.rb @@ -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 diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb index 8e5a832663..b037e29fac 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb @@ -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 }