mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Support datastore migration during VM migration
This commit is contained in:
parent
df1bb63566
commit
9bf6d37858
@ -43,7 +43,7 @@ begin
|
||||
exit 0 if OpenNebula.is_disk?(dst_path)
|
||||
exit 0 if src == dst
|
||||
|
||||
VCenterDriver::VirtualMachine.migrate_routine(vmid, host_orig, host_dest)
|
||||
VCenterDriver::VirtualMachine.migrate_routine(vmid, host_orig, host_dest, dsid)
|
||||
|
||||
rescue StandardError => e
|
||||
message = "Cannot migrate for VM #{vmid}"\
|
||||
|
@ -2180,10 +2180,11 @@ class VirtualMachine < VCenterDriver::Template
|
||||
# retrieve host from DRS
|
||||
resourcepool = config[:cluster].resourcePool
|
||||
|
||||
#relocate_spec_params = {}
|
||||
#relocate_spec_params[:pool] = resourcepool
|
||||
#relocate_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(relocate_spec_params)
|
||||
#@item.RelocateVM_Task(spec: relocate_spec, priority: "defaultPriority").wait_for_completion
|
||||
relocate_spec_params = {}
|
||||
relocate_spec_params[:pool] = resourcepool
|
||||
relocate_spec_params[:datastore] = config[:datastore]
|
||||
relocate_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(relocate_spec_params)
|
||||
@item.RelocateVM_Task(spec: relocate_spec, priority: "defaultPriority").wait_for_completion
|
||||
|
||||
@item.MigrateVM_Task(:pool=> resourcepool, :priority => "defaultPriority").wait_for_completion
|
||||
|
||||
@ -2639,8 +2640,12 @@ class VirtualMachine < VCenterDriver::Template
|
||||
pool = OpenNebula::HostPool.new(one_client)
|
||||
pool.info
|
||||
|
||||
datastores = OpenNebula::DatastorePool.new(one_client)
|
||||
datastores.info
|
||||
|
||||
src_id = pool["/HOST_POOL/HOST[NAME='#{src_host}']/ID"].to_i
|
||||
dst_id = pool["/HOST_POOL/HOST[NAME='#{dst_host}']/ID"].to_i
|
||||
datastore = datastores["/DATASTORE_POOL/DATASTORE[ID='#{ds}']/TEMPLATE/VCENTER_DS_REF"]
|
||||
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(src_id)
|
||||
|
||||
@ -2657,7 +2662,7 @@ class VirtualMachine < VCenterDriver::Template
|
||||
ccr_ref = dst_host['/HOST/TEMPLATE/VCENTER_CCR_REF']
|
||||
vc_host = VCenterDriver::ClusterComputeResource.new_from_ref(ccr_ref, vi_client).item
|
||||
|
||||
config = { :cluster => vc_host }
|
||||
config = { :cluster => vc_host, :datastore => datastore }
|
||||
vc_vm.migrate(config)
|
||||
|
||||
vm.replace({ 'VCENTER_CCR_REF' => ccr_ref})
|
||||
|
Loading…
x
Reference in New Issue
Block a user