From ffce456de9dde6868507efc9859e6f785585e5ac Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Thu, 18 Apr 2019 09:26:30 +0530 Subject: [PATCH] VMware: Check return of FindByInventoryPath (#55282) Check return value of FindByInventoryPath API which is used for finding desired folder to deploy OVF. Fixes: #54823 Signed-off-by: Abhijeet Kasurde --- changelogs/fragments/54823-vmware_deploy_ovf-folder.yml | 2 ++ lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/54823-vmware_deploy_ovf-folder.yml diff --git a/changelogs/fragments/54823-vmware_deploy_ovf-folder.yml b/changelogs/fragments/54823-vmware_deploy_ovf-folder.yml new file mode 100644 index 0000000000..e856eea087 --- /dev/null +++ b/changelogs/fragments/54823-vmware_deploy_ovf-folder.yml @@ -0,0 +1,2 @@ +minor_changes: + - Check return value of FindByInventoryPath API used for finding folder value (https://github.com/ansible/ansible/issues/54823). diff --git a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py index 815e7f1430..0ac652849d 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py +++ b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py @@ -370,6 +370,8 @@ class VMwareDeployOvf: if self.params['folder']: folder = self.si.searchIndex.FindByInventoryPath(self.params['folder']) + if not folder: + self.module.fail_json(msg="Unable to find the specified folder %(folder)s" % self.params) else: folder = datacenter.vmFolder