ManageIQ Ivanchuk fixes (#63948)

- manageiq-group: better handling if key not present
- manageiq-tenant: ivanchuk api now returns ids as strings
pull/63950/head
Evert Mulder 5 years ago committed by John R Barker
parent 3aaebba235
commit 5e9638c869

@ -411,11 +411,7 @@ class ManageIQgroup(object):
filters_updated = False filters_updated = False
new_filters_resource = {} new_filters_resource = {}
# Process belongsto filters current_belongsto_set = current_filters.get('belongsto', set())
if 'belongsto' in current_filters:
current_belongsto_set = set(current_filters['belongsto'])
else:
current_belongsto_set = set()
if belongsto_filters: if belongsto_filters:
new_belongsto_set = set(belongsto_filters) new_belongsto_set = set(belongsto_filters)
@ -501,11 +497,12 @@ class ManageIQgroup(object):
@staticmethod @staticmethod
def manageiq_filters_to_sorted_dict(current_filters): 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 return None
res = {} res = {}
for tag_list in current_filters['managed']: for tag_list in current_managed_filters:
tag_list.sort() tag_list.sort()
key = tag_list[0].split('/')[2] key = tag_list[0].split('/')[2]
res[key] = tag_list res[key] = tag_list
@ -547,11 +544,11 @@ class ManageIQgroup(object):
belongsto_filters = None belongsto_filters = None
if 'filters' in group['entitlement']: if 'filters' in group['entitlement']:
filters = group['entitlement']['filters'] filters = group['entitlement']['filters']
if 'belongsto' in filters: belongsto_filters = filters.get('belongsto')
belongsto_filters = filters['belongsto'] group_managed_filters = filters.get('managed')
if 'managed' in filters: if group_managed_filters:
managed_filters = {} managed_filters = {}
for tag_list in filters['managed']: for tag_list in group_managed_filters:
key = tag_list[0].split('/')[2] key = tag_list[0].split('/')[2]
tags = [] tags = []
for t in tag_list: for t in tag_list:

@ -221,7 +221,7 @@ class ManageIQTenant(object):
self.module.fail_json(msg="Multiple parent tenants not found in manageiq with name '%s" % parent) self.module.fail_json(msg="Multiple parent tenants not found in manageiq with name '%s" % parent)
parent_tenant = parent_tenant_res[0] 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) tenants = self.client.collections.tenants.find_by(name=name)
for tenant in tenants: for tenant in tenants:
@ -448,7 +448,7 @@ class ManageIQTenant(object):
try: try:
ancestry = tenant['ancestry'] ancestry = tenant['ancestry']
tenant_parent_id = int(ancestry.split("/")[-1]) tenant_parent_id = ancestry.split("/")[-1]
except AttributeError: except AttributeError:
# The root tenant does not return the ancestry attribute # The root tenant does not return the ancestry attribute
tenant_parent_id = None tenant_parent_id = None

Loading…
Cancel
Save