From 4391f5c094dba91fbc739fc2e038ed4d6bd8b7ec Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Thu, 14 Dec 2017 19:13:23 +0530 Subject: [PATCH] VMware: Handle No Permission exception while clone (#33806) This fix adds exception handling for No Permission exception raised while clone operation. Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/cloud/vmware/vmware_guest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 9de5051d366..83af724a0ae 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -1451,7 +1451,13 @@ class PyVmomiHelper(PyVmomi): clonespec.config = self.configspec clone_method = 'Clone' - task = vm_obj.Clone(folder=destfolder, name=self.params['name'], spec=clonespec) + try: + task = vm_obj.Clone(folder=destfolder, name=self.params['name'], spec=clonespec) + except vim.fault.NoPermission as e: + self.module.fail_json(msg="Failed to clone virtual machine %s to folder %s " + "due to permission issue: %s" % (self.params['name'], + destfolder, + to_native(e.msg))) self.change_detected = True else: # ConfigSpec require name for VM creation