Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for nested resource pools #1

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions plugins/modules/vmware_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2884,12 +2884,19 @@ def get_resource_pool(self, cluster=None, host=None, resource_pool=None):
cluster = None

# get resource pools limiting search to cluster or datacenter
resource_pool = find_obj(self.content, [vim.ResourcePool], resource_pool_name, folder=cluster or datacenter)
if not resource_pool:
if resource_pool_name:
self.module.fail_json(msg='Unable to find resource_pool "%s"' % resource_pool_name)
resource_pool = find_obj(self.content, [vim.ResourcePool], None, folder=cluster or datacenter)
if not resource_pool:
self.module.fail_json(msg='Unable to find resource pool, need esxi_hostname, resource_pool, or cluster')
resource_pool_path = resource_pool_name.split('/') if resource_pool_name else []
# filter path from empty items
rp_path_nodes = list(filter(None, resource_pool_path))
for i in range(len(rp_path_nodes)):
child = list(filter(lambda x: x.name == rp_path_nodes[i], resource_pool.resourcePool))
if len(child) != 1:
self.module.fail_json(msg='Unable to find node "%s" in resource pool path "%s"' % (rp_path_nodes[i], resource_pool_name))
break
else:
self.module.fail_json(msg='Unable to find resource pool, need esxi_hostname, resource_pool, or cluster')
resource_pool = child[0]
return resource_pool

def deploy_vm(self):
Expand Down