Skip to content

Commit

Permalink
ManageIQ Ivanchuk fixes (ansible#63948)
Browse files Browse the repository at this point in the history
- manageiq-group: better handling if key not present
- manageiq-tenant: ivanchuk api now returns ids as strings
  • Loading branch information
evertmulder authored and gundalow committed Oct 25, 2019
1 parent 3aaebba commit 5e9638c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 8 additions & 11 deletions lib/ansible/modules/remote_management/manageiq/manageiq_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,7 @@ def edit_group_edit_filters(self, current_filters, norm_managed_filters, managed
filters_updated = False
new_filters_resource = {}

# Process belongsto filters
if 'belongsto' in current_filters:
current_belongsto_set = set(current_filters['belongsto'])
else:
current_belongsto_set = set()
current_belongsto_set = current_filters.get('belongsto', set())

if belongsto_filters:
new_belongsto_set = set(belongsto_filters)
Expand Down Expand Up @@ -501,11 +497,12 @@ def normalized_managed_tag_filters_to_miq(norm_managed_filters):

@staticmethod
def manageiq_filters_to_sorted_dict(current_filters):
if 'managed' not in current_filters:
current_managed_filters = current_filters.get('managed')
if not current_managed_filters:
return None

res = {}
for tag_list in current_filters['managed']:
for tag_list in current_managed_filters:
tag_list.sort()
key = tag_list[0].split('/')[2]
res[key] = tag_list
Expand Down Expand Up @@ -547,11 +544,11 @@ def create_result_group(group):
belongsto_filters = None
if 'filters' in group['entitlement']:
filters = group['entitlement']['filters']
if 'belongsto' in filters:
belongsto_filters = filters['belongsto']
if 'managed' in filters:
belongsto_filters = filters.get('belongsto')
group_managed_filters = filters.get('managed')
if group_managed_filters:
managed_filters = {}
for tag_list in filters['managed']:
for tag_list in group_managed_filters:
key = tag_list[0].split('/')[2]
tags = []
for t in tag_list:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def tenant(self, name, parent_id, parent):
self.module.fail_json(msg="Multiple parent tenants not found in manageiq with name '%s" % parent)

parent_tenant = parent_tenant_res[0]
parent_id = parent_tenant['id']
parent_id = int(parent_tenant['id'])
tenants = self.client.collections.tenants.find_by(name=name)

for tenant in tenants:
Expand Down Expand Up @@ -448,7 +448,7 @@ def create_tenant_response(self, tenant, parent_tenant):

try:
ancestry = tenant['ancestry']
tenant_parent_id = int(ancestry.split("/")[-1])
tenant_parent_id = ancestry.split("/")[-1]
except AttributeError:
# The root tenant does not return the ancestry attribute
tenant_parent_id = None
Expand Down

0 comments on commit 5e9638c

Please sign in to comment.