From b9ec7bb2532a55cdb7d6c7697453dc26553d8139 Mon Sep 17 00:00:00 2001 From: thefaftek Date: Thu, 7 Mar 2019 22:09:55 -0600 Subject: [PATCH] VMware: fail module when unable to find the user specified folder (#53474) --- lib/ansible/modules/cloud/vmware/vmware_guest_move.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_move.py b/lib/ansible/modules/cloud/vmware/vmware_guest_move.py index ccc0445a77..255a658252 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_move.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_move.py @@ -185,7 +185,6 @@ def main(): # FindByInventoryPath() does not require an absolute path # so we should leave the input folder path unmodified module.params['dest_folder'] = module.params['dest_folder'].rstrip('/') - pyv = PyVmomiHelper(module) search_index = pyv.content.searchIndex @@ -199,6 +198,8 @@ def main(): vm_full = vm_path + '/' + module.params['name'] folder = search_index.FindByInventoryPath( module.params['dest_folder']) + if folder is None: + module.fail_json(msg="Folder name and/or path does not exist") vm_to_move = search_index.FindByInventoryPath(vm_full) if vm_path != module.params['dest_folder'].lstrip('/'): move_task = folder.MoveInto([vm_to_move])