mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-02 14:29:10 -07:00
Apply fix to allow the root resource pool of a cluster to be chosen (#31641)
Whitespace cleanup
This commit is contained in:
parent
639bac11d4
commit
4756b392ea
3 changed files with 271 additions and 4 deletions
|
@ -1198,17 +1198,24 @@ class PyVmomiHelper(PyVmomi):
|
|||
return root
|
||||
|
||||
def get_resource_pool(self):
|
||||
|
||||
resource_pool = None
|
||||
|
||||
if self.params['esxi_hostname']:
|
||||
# highest priority, resource_pool given.
|
||||
if self.params['resource_pool']:
|
||||
resource_pool = self.select_resource_pool_by_name(self.params['resource_pool'])
|
||||
# next priority, esxi hostname given.
|
||||
elif self.params['esxi_hostname']:
|
||||
host = self.select_host()
|
||||
resource_pool = self.select_resource_pool_by_host(host)
|
||||
# next priority, cluster given, take the root of the pool
|
||||
elif self.params['cluster']:
|
||||
cluster = self.cache.get_cluster(self.params['cluster'])
|
||||
resource_pool = cluster.resourcePool
|
||||
# fallback, pick any RP
|
||||
else:
|
||||
resource_pool = self.select_resource_pool_by_name(self.params['resource_pool'])
|
||||
|
||||
if resource_pool is None:
|
||||
self.module.fail_json(msg='Unable to find resource pool "%(resource_pool)s"' % self.params)
|
||||
self.module.fail_json(msg='Unable to find resource pool, need esxi_hostname, resource_pool, or cluster')
|
||||
|
||||
return resource_pool
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue