mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
Live migration using RR and host tag
This commit is contained in:
parent
9de1a9d4a6
commit
1e445b83a7
@ -50,7 +50,7 @@ begin
|
||||
if src_ds == dsid
|
||||
VCenterDriver::VirtualMachine.migrate_routine(vmid, host_orig, host_dest)
|
||||
else
|
||||
VCenterDriver::VirtualMachine.migrate_routine(vmid, host_orig, host_dest, dsid)
|
||||
VCenterDriver::VirtualMachine.migrate_routine(vmid, host_orig, host_dest, false, dsid)
|
||||
end
|
||||
|
||||
rescue StandardError => e
|
||||
|
@ -2460,16 +2460,24 @@ class VirtualMachine < VCenterDriver::Template
|
||||
begin
|
||||
# retrieve host from DRS
|
||||
resourcepool = config[:cluster].resourcePool
|
||||
host = config[:cluster].host.first
|
||||
datastore = config[:datastore]
|
||||
|
||||
if datastore
|
||||
relocate_spec_params = {
|
||||
pool: resourcepool,
|
||||
host: host,
|
||||
datastore: datastore,
|
||||
}
|
||||
|
||||
if config[:esx_migration_list].is_a?(String)
|
||||
if config[:esx_migration_list]==""
|
||||
relocate_spec_params[:host] = config[:cluster].host.sample
|
||||
elsif config[:esx_migration_list]!="Selected_by_DRS"
|
||||
hosts = config[:esx_migration_list].split(' ')
|
||||
relocate_spec_params[:host] = hosts.sample
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
relocate_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(relocate_spec_params)
|
||||
@item.RelocateVM_Task(spec: relocate_spec, priority: "defaultPriority").wait_for_completion
|
||||
else
|
||||
@ -2923,7 +2931,7 @@ class VirtualMachine < VCenterDriver::Template
|
||||
return one_vm
|
||||
end
|
||||
|
||||
def self.migrate_routine(vm_id, src_host, dst_host, ds = nil)
|
||||
def self.migrate_routine(vm_id, src_host, dst_host, hot_ds = false, ds = nil)
|
||||
one_client = OpenNebula::Client.new
|
||||
pool = OpenNebula::HostPool.new(one_client)
|
||||
pool.info
|
||||
@ -2948,6 +2956,8 @@ class VirtualMachine < VCenterDriver::Template
|
||||
vm.info
|
||||
dst_host.info
|
||||
|
||||
esx_migration_list = dst_host['/HOST/TEMPLATE/ESX_MIGRATION_LIST']
|
||||
|
||||
# required vcenter objects
|
||||
vc_vm = VCenterDriver::VirtualMachine.new_without_id(vi_client, vm['/VM/DEPLOY_ID'])
|
||||
ccr_ref = dst_host['/HOST/TEMPLATE/VCENTER_CCR_REF']
|
||||
@ -2956,6 +2966,12 @@ class VirtualMachine < VCenterDriver::Template
|
||||
config = { :cluster => vc_host }
|
||||
|
||||
config[:datastore] = datastore if datastore
|
||||
if hot_ds
|
||||
config[:esx_migration_list] = esx_migration_list if esx_migration_list
|
||||
else
|
||||
config[:esx_migration_list] = "Selected_by_DRS"
|
||||
end
|
||||
|
||||
vc_vm.migrate(config)
|
||||
|
||||
vm.replace({ 'VCENTER_CCR_REF' => ccr_ref})
|
||||
|
@ -32,7 +32,7 @@ require 'vcenter_driver'
|
||||
vm_id = ARGV[-2]
|
||||
src_host = ARGV[-3]
|
||||
dst_host = ARGV[-4]
|
||||
dsid = "111"
|
||||
#dsid = "111"
|
||||
|
||||
begin
|
||||
|
||||
@ -44,7 +44,7 @@ begin
|
||||
if src_ds == dsid
|
||||
VCenterDriver::VirtualMachine.migrate_routine(vm_id, src_host, dst_host)
|
||||
else
|
||||
VCenterDriver::VirtualMachine.migrate_routine(vm_id, src_host, dst_host, dsid)
|
||||
VCenterDriver::VirtualMachine.migrate_routine(vm_id, src_host, dst_host, true, dsid)
|
||||
end
|
||||
|
||||
rescue StandardError => e
|
||||
|
Loading…
x
Reference in New Issue
Block a user