diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 383d0c8b12..a236ba5b64 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -433,7 +433,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header("WILD VIRTUAL MACHINES", false) puts - format = "%30s %36s %4s %10s" + format = "%-30.30s %36s %4s %10s" CLIHelper.print_header(format % ["NAME", "IMPORT_ID", "CPU", "MEMORY"], true) diff --git a/src/cli/onehost b/src/cli/onehost index a1013d5c26..1c886e1be4 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -244,7 +244,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do Import VM to OpenNebula EOT - command :importvm, importvm_desc, :hostid, :import_id do + command :importvm, importvm_desc, :hostid, :name do helper.perform_action(args[0], options, "imported") do |o| rc = o.info next rc if OpenNebula.is_error?(rc) diff --git a/src/vmm_mad/remotes/sl/sl_driver.rb b/src/vmm_mad/remotes/sl/sl_driver.rb index 9b1cac1ed0..0cdbfaa006 100644 --- a/src/vmm_mad/remotes/sl/sl_driver.rb +++ b/src/vmm_mad/remotes/sl/sl_driver.rb @@ -304,7 +304,7 @@ class SLDriver vms_info << "VM=[\n" vms_info << " ID=#{one_id || -1},\n" - vms_info << " VM_NAME=#{i['id']},\n" + vms_info << " VM_NAME=#{i['fullyQualifiedDomainName']},\n" vms_info << " IMPORT_TEMPLATE=\"#{vm_template_to_one}\",\n" vms_info << " DEPLOY_ID=#{i['id']},\n" vms_info << " POLL=\"#{poll_data[0...-1]}\" ]\n" diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index 62aab404ff..9aa6d93ab2 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -143,6 +143,20 @@ class VIClient return conn end + ######################################################################## + # The associated cluster for this connection + ######################################################################## + def cluster + @cluster + end + + ######################################################################## + # The associated cluster for this connection + ######################################################################## + def rp_confined? + !@one_host["TEMPLATE/VCENTER_RESOURCE_POOL"].nil? + end + ######################################################################## # The associated resource pool for this connection ######################################################################## @@ -150,9 +164,11 @@ class VIClient rp_name = @one_host["TEMPLATE/VCENTER_RESOURCE_POOL"] if rp_name.nil? - @cluster.resourcePool + rp_array = @cluster.resourcePool.resourcePool + rp_array << @cluster.resourcePool + rp_array else - find_resource_pool(rp_name) + [find_resource_pool(rp_name)] end end @@ -574,7 +590,7 @@ class VCenterHost < ::OpenNebula::Host @client = client @cluster = client.cluster - @resource_pool = client.resource_pool + @resource_pools = client.resource_pool end ######################################################################## @@ -709,35 +725,38 @@ class VCenterHost < ::OpenNebula::Host def monitor_vms str_info = "" - @resource_pool.vm.each { |v| - begin - name = v.name - number = -1 + @resource_pools.each{|rp| + rp.vm.each { |v| + begin + name = v.name + number = -1 - matches = name.match(/^one-(\d*)(-(.*))?$/) - number = matches[1] if matches + matches = name.match(/^one-(\d*)(-(.*))?$/) + number = matches[1] if matches - vm = VCenterVm.new(@client, v) - vm.monitor + vm = VCenterVm.new(@client, v) + vm.monitor - next if !vm.vm.config + next if !vm.vm.config - str_info << "\nVM = [" - str_info << "ID=#{number}," - str_info << "DEPLOY_ID=\"#{vm.vm.config.uuid}\"," - str_info << "VM_NAME=\"#{name}\"," + str_info << "\nVM = [" + str_info << "ID=#{number}," + str_info << "DEPLOY_ID=\"#{vm.vm.config.uuid}\"," + str_info << "VM_NAME=\"#{name} - "\ + "#{v.runtime.host.parent.name}\"," - if number == -1 - vm_template_to_one = - Base64.encode64(vm.vm_to_one).gsub("\n","") - str_info << "IMPORT_TEMPLATE=\"#{vm_template_to_one}\"," + if number == -1 + vm_template_to_one = + Base64.encode64(vm.vm_to_one).gsub("\n","") + str_info << "IMPORT_TEMPLATE=\"#{vm_template_to_one}\"," + end + + str_info << "POLL=\"#{vm.info}\"]" + rescue Exception => e + STDERR.puts e.inspect + STDERR.puts e.backtrace end - - str_info << "POLL=\"#{vm.info}\"]" - rescue Exception => e - STDERR.puts e.inspect - STDERR.puts e.backtrace - end + } } return str_info @@ -1395,9 +1414,15 @@ private connection = VIClient.new(hid) vc_template = connection.find_vm_template(uuid) + if connection.rp_confined? + rp = connection.cluster.resource_pool.first + else + rp = connection.cluster.resourcePool + end + relocate_spec = RbVmomi::VIM.VirtualMachineRelocateSpec( :diskMoveType => :moveChildMostDiskBacking, - :pool => connection.resource_pool) + :pool => rp) clone_parameters = { :location => relocate_spec,