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 <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-04-17 14:58:00 +05:30 committed by ansibot
parent efc3f4f824
commit 93fbfbe4cf

View file

@ -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: