From 827dd9483310aed2af13368036001068c1cb4393 Mon Sep 17 00:00:00 2001 From: Sergio Vega Date: Thu, 4 Apr 2019 12:57:31 -0600 Subject: [PATCH] F #2505: Allow detach disks for VM with snapshots --- src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb index 15b0e7fd9b1..07e638b9bb1 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb @@ -2012,7 +2012,8 @@ def detach_disk(disk) begin @item.ReconfigVM_Task(:spec => spec_hash).wait_for_completion rescue Exception => e - raise "Cannot detach DISK from VM: #{e.message}\n#{e.backtrace}" + raise "Cannot detach DISK from VM: #{e.message}\n#{e.backtrace}"\ + "Probably an existing VM snapshot includes that disk" end end @@ -2020,9 +2021,9 @@ def destroy_disk(disk) one_vm = one_item detachable= !(one_vm["LCM_STATE"].to_i == 11 && !disk.managed?) - detachable = detachable && !has_snapshots? && disk.exists? + detachable = detachable && disk.exists? - return unless detachable + raise "Can not detach disk. Not supported on current configuration" unless detachable detach_disk(disk) disk.destroy()