mirror of
https://github.com/ansible/awx.git
synced 2026-03-08 05:01:09 -02:30
Fix for traceback when using nested groups.
This commit is contained in:
@@ -577,15 +577,18 @@ class Ec2Inventory(object):
|
|||||||
def push(self, my_dict, key, element):
|
def push(self, my_dict, key, element):
|
||||||
''' Pushed an element onto an array that may not have been defined in
|
''' Pushed an element onto an array that may not have been defined in
|
||||||
the dict '''
|
the dict '''
|
||||||
|
group_info = my_dict.setdefault(key, [])
|
||||||
if key in my_dict:
|
if isinstance(group_info, dict):
|
||||||
my_dict[key].append(element);
|
host_list = group_info.setdefault('hosts', [])
|
||||||
|
host_list.append(element)
|
||||||
else:
|
else:
|
||||||
my_dict[key] = [element]
|
group_info.append(element)
|
||||||
|
|
||||||
def push_group(self, my_dict, key, element):
|
def push_group(self, my_dict, key, element):
|
||||||
'''Push a group as a child of another group.'''
|
''' Push a group as a child of another group. '''
|
||||||
parent_group = my_dict.setdefault(key, {})
|
parent_group = my_dict.setdefault(key, {})
|
||||||
|
if not isinstance(parent_group, dict):
|
||||||
|
parent_group = my_dict[key] = {'hosts': parent_group}
|
||||||
child_groups = parent_group.setdefault('children', [])
|
child_groups = parent_group.setdefault('children', [])
|
||||||
if element not in child_groups:
|
if element not in child_groups:
|
||||||
child_groups.append(element)
|
child_groups.append(element)
|
||||||
|
|||||||
Reference in New Issue
Block a user