B #2951: persistent disks problem with snapshot solved

This commit is contained in:
sergio semedi committed 2019-02-18 08:43:15 +01:00
1 parent e778335bf6
commit 53cd9541e0
3 files changed
+6 -4

No files matched your search

+1 -1
View File
@@ -70,7 +70,7 @@ begin
vm = VCenterDriver::VirtualMachine.new(vi_client, vm_ref, vmid)
if vm.has_snapshots?
STDERR.puts "'disk-saveas' operation is not supported for VMs with system snapshots."
raise "'disk-saveas' operation is not supported for VMs with system snapshots."
exit 1
end
+4 -2
View File
@@ -61,11 +61,13 @@ disk_id = img_path.split(".")[-1]
begin
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
vm = VCenterDriver::VirtualMachine.new(vi_client, vm_ref, vmid)
disk = vm.disk(disk_id)
vmperst = vm.instantiated_as_persistent?
vm.remove_all_snapshots if vm.has_snapshots?
disk = vm.disk(disk_id)
# Don't detach persistent disks if the VM has snapshots
if disk && disk.exists? && !vm.has_snapshots?
if disk && disk.exists?
vm.one_item = one_vm
# Do not detach persistent unmanaged disk, we need them for mark as a template
@@ -1009,8 +1009,8 @@ class VirtualMachine < VCenterDriver::Template
if key
query = vc_disks.select {|dev| key == dev[:key]}
else
error = 'disk metadata is corrupted and you have snapshots'
if has_snapshots?
error = 'disk metadata is corrupted and you have snapshots'
raise error
end