Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
vmdk_ops: Check attached status in removeVMDK before trying to remove…
Browse files Browse the repository at this point in the history
… the volume
  • Loading branch information
brunotm committed Nov 8, 2016
1 parent 1024227 commit f29b876
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion esx_service/vmdk_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,17 @@ def vol_info(vol_meta, vol_size_info, datastore):
# Return error, or None for OK
def removeVMDK(vmdk_path):
logging.info("*** removeVMDK: %s", vmdk_path)
cmd = "{0} {1}".format(VMDK_DELETE_CMD, vmdk_path)

# Check the current volume status
attached, uuid, attach_as = getStatusAttached(vmdk_path)
if attached:
vm = findVmByUuid(uuid)
logging.info("*** removeVMDK: %s is in use by %s VM uuid = %s",
vmdk_path, vm.config.name, uuid)
return err("Failed to remove volume {0}, is in use by VM {1}.".format(
vmdk_path, vm.config.name))

cmd = "{0} {1}".format(VMDK_DELETE_CMD, vmdk_path)
# Workaround timing/locking issues.
retry_count = 0
while True:
Expand Down

0 comments on commit f29b876

Please # to comment.