From 93fbfbe4cf64002e2c28aedb83947c9ce2f0f17d Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 17 Apr 2018 14:58:00 +0530 Subject: [PATCH] VMware: Check if cluster exists or not (#38517) This fix adds a check if Datacenter contains cluster but does not have ESXi server associated with that cluster. Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/cloud/vmware/vmware_guest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 36f4dd5d68b..69ba777e692 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -1722,6 +1722,8 @@ class PyVmomiHelper(PyVmomi): # next priority, cluster given, take the root of the pool elif self.params['cluster']: cluster = self.cache.get_cluster(self.params['cluster']) + if cluster is None: + self.module.fail_json(msg="Unable to find cluster '%(cluster)s'" % self.params) resource_pool = cluster.resourcePool # fallback, pick any RP else: