mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
F #2875: Support vCenter managed disk in DS migration
This commit is contained in:
parent
53cd9541e0
commit
12b91e4484
@ -385,13 +385,15 @@ class Datastore < Storage
|
||||
target_ds_vc = VCenterDriver::Datastore.new_from_ref(target_ds_ref, vi_client)
|
||||
dest_name = target_ds_vc['name']
|
||||
|
||||
dest_path = "[#{dest_name}] #{dest_path}"
|
||||
target_ds_vc.create_directory(File.dirname(dest_path))
|
||||
|
||||
dpath_ds = "[#{dest_name}] #{dest_path}"
|
||||
orig_path = "[#{self['name']}] #{disk.path}"
|
||||
|
||||
move_params = {
|
||||
sourceName: orig_path,
|
||||
sourceDatacenter: get_dc.item,
|
||||
destName: dest_path,
|
||||
destName: dpath_ds,
|
||||
force: true
|
||||
}
|
||||
|
||||
|
@ -2990,10 +2990,6 @@ class VirtualMachine < VCenterDriver::Template
|
||||
vc_vm = VCenterDriver::VirtualMachine.new_without_id(vi_client, vm['/VM/DEPLOY_ID'])
|
||||
|
||||
vc_vm.vm_id = vm_id
|
||||
error = !vc_vm.disks_each(:managed?).empty? && !ds.nil?
|
||||
# We know this comes from a migration from poweroff state (not a poweroff migration)
|
||||
# since all the other cases are treated in vmm drivers: save, migrate and shutdown
|
||||
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)
|
||||
|
@ -48,16 +48,6 @@ begin
|
||||
|
||||
vm = VCenterDriver::VirtualMachine.new(vi_client, vm_ref, vm_id)
|
||||
|
||||
if (%{'SAVE_MIGRATE'}).include?(lcm_state_str)
|
||||
dst_ds = drv_action['VM/HISTORY_RECORDS/HISTORY/DS_ID']
|
||||
src_ds = drv_action['DATASTORE/ID']
|
||||
|
||||
new_ds = dst_ds != src_ds
|
||||
|
||||
error = !vm.disks_each(:managed?).empty? && new_ds
|
||||
raise 'cold datastore migration in poweroff hard with managed disk(s) is not supported' if error
|
||||
end
|
||||
|
||||
vm.poweroff_hard
|
||||
rescue StandardError => e
|
||||
message = "Cancel VM #{vm_ref} failed due to "\
|
||||
|
@ -29,7 +29,6 @@ $LOAD_PATH << File.dirname(__FILE__)
|
||||
|
||||
require 'vcenter_driver'
|
||||
|
||||
vm_ref = ARGV[0]
|
||||
vm_id = ARGV[-2]
|
||||
src_host = ARGV[-3]
|
||||
dst_host = ARGV[-4]
|
||||
@ -41,12 +40,7 @@ dst_ds = drv_action['VM/HISTORY_RECORDS/HISTORY/DS_ID']
|
||||
src_ds = drv_action['DATASTORE/ID']
|
||||
|
||||
begin
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(src_host)
|
||||
vm = VCenterDriver::VirtualMachine.new(vi_client, vm_ref, vm_id)
|
||||
new_ds = dst_ds != src_ds
|
||||
|
||||
error = !vm.disks_each(:managed?).empty? && new_ds
|
||||
raise 'live datastore migration with managed disk is not supported' if error
|
||||
new_ds = dst_ds != src_ds
|
||||
|
||||
if new_ds
|
||||
VCenterDriver::VirtualMachine
|
||||
|
@ -55,19 +55,7 @@ begin
|
||||
|
||||
vm = VCenterDriver::VirtualMachine.new_without_id(vi_client, vm_ref)
|
||||
|
||||
if (%{'SAVE_MIGRATE'}).include?(lcm_state_str)
|
||||
vm.vm_id = vm_id
|
||||
dst_ds = drv_action['VM/HISTORY_RECORDS/HISTORY/DS_ID']
|
||||
src_ds = drv_action['DATASTORE/ID']
|
||||
|
||||
new_ds = dst_ds != src_ds
|
||||
|
||||
error = !vm.disks_each(:managed?).empty? && new_ds
|
||||
raise 'cold datastore migration with managed disk(s) is not supported' if error
|
||||
end
|
||||
|
||||
vm.suspend
|
||||
|
||||
rescue StandardError => e
|
||||
message = "Save of VM #{vm_ref} on vCenter cluster "\
|
||||
"#{vc_cluster_name} failed due to "\
|
||||
|
@ -62,19 +62,6 @@ begin
|
||||
|
||||
vm = VCenterDriver::VirtualMachine.new_without_id(vi_client, vm_ref)
|
||||
|
||||
|
||||
if (%{'SAVE_MIGRATE'}).include?(lcm_state_str)
|
||||
vm.vm_id = vm_id
|
||||
dst_ds = drv_action['VM/HISTORY_RECORDS/HISTORY/DS_ID']
|
||||
src_ds = drv_action['DATASTORE/ID']
|
||||
|
||||
new_ds = dst_ds != src_ds
|
||||
|
||||
error = !vm.disks_each(:managed?).empty? && new_ds
|
||||
raise 'cold datastore migration in poweroff with managed disk(s) is not supported' if error
|
||||
end
|
||||
|
||||
|
||||
vm.shutdown # Undeploy, Poweroff or Terminate
|
||||
rescue StandardError => e
|
||||
message = "Shutdown of VM #{vm_ref} on vCenter cluster "\
|
||||
|
Loading…
x
Reference in New Issue
Block a user