From 20c143f754a6f46865556b79bc4a03833d8ad53a Mon Sep 17 00:00:00 2001 From: Bruno Moura Date: Wed, 23 Nov 2016 21:40:10 +0000 Subject: [PATCH] vmdk_ops.cloneVMDK: Fix source volume lockname --- esx_service/vmdk_ops.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/esx_service/vmdk_ops.py b/esx_service/vmdk_ops.py index e43c4845a..ab37c173d 100755 --- a/esx_service/vmdk_ops.py +++ b/esx_service/vmdk_ops.py @@ -262,7 +262,11 @@ def cloneVMDK(vm_name, vmdk_path, opts={}, vm_uuid=None, vm_datastore=None): if not os.path.isfile(src_vmdk_path): return err("Could not find volume for cloning %s" % opts[kv.CLONE_FROM]) - with lockManager.get_lock(src_volume): + # Form datastore path from vmdk_path + dest_vol = vmdk_utils.get_datastore_path(vmdk_path) + source_vol = vmdk_utils.get_datastore_path(src_vmdk_path) + + with lockManager.get_lock(source_vol): # Verify if the source volume is in use. attached, uuid, attach_as = getStatusAttached(src_vmdk_path) if attached: @@ -289,10 +293,7 @@ def cloneVMDK(vm_name, vmdk_path, opts={}, vm_uuid=None, vm_datastore=None): vdisk_spec.adapterType = 'busLogic' vdisk_spec.diskType = disk_format - # Form datastore path from vmdk_path - dest_vol = vmdk_utils.get_datastore_path(vmdk_path) - source_vol = vmdk_utils.get_datastore_path(src_vmdk_path) - + # Clone volume si = get_si() task = si.content.virtualDiskManager.CopyVirtualDisk( sourceName=source_vol, destName=dest_vol, destSpec=vdisk_spec)