Skip to content

Commit

Permalink
F #2505: Allow detach disks for VM with snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiojvg committed Apr 4, 2019
1 parent a9bf594 commit 827dd94
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2012,17 +2012,18 @@ 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

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()
Expand Down

0 comments on commit 827dd94

Please sign in to comment.