mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
Merge pull request #6409 from AlanCoding/group_children
Rename group-to-group field to align with API Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -47,12 +47,14 @@ options:
|
|||||||
required: False
|
required: False
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
groups:
|
children:
|
||||||
description:
|
description:
|
||||||
- List of groups that should be nested inside in this group.
|
- List of groups that should be nested inside in this group.
|
||||||
required: False
|
required: False
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
aliases:
|
||||||
|
- groups
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Desired state of the resource.
|
- Desired state of the resource.
|
||||||
@@ -98,7 +100,7 @@ def main():
|
|||||||
inventory=dict(required=True),
|
inventory=dict(required=True),
|
||||||
variables=dict(type='dict', required=False),
|
variables=dict(type='dict', required=False),
|
||||||
hosts=dict(type='list', elements='str'),
|
hosts=dict(type='list', elements='str'),
|
||||||
groups=dict(type='list', elements='str'),
|
children=dict(type='list', elements='str', aliases=['groups']),
|
||||||
state=dict(choices=['present', 'absent'], default='present'),
|
state=dict(choices=['present', 'absent'], default='present'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -136,7 +138,7 @@ def main():
|
|||||||
|
|
||||||
association_fields = {}
|
association_fields = {}
|
||||||
for resource, relationship in (('hosts', 'hosts'), ('groups', 'children')):
|
for resource, relationship in (('hosts', 'hosts'), ('groups', 'children')):
|
||||||
name_list = module.params.get(resource)
|
name_list = module.params.get(relationship)
|
||||||
if name_list is None:
|
if name_list is None:
|
||||||
continue
|
continue
|
||||||
id_list = []
|
id_list = []
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def test_create_group(run_module, admin_user):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_associate_hosts_and_groups(run_module, admin_user, organization):
|
def test_associate_hosts_and_children(run_module, admin_user, organization):
|
||||||
inv = Inventory.objects.create(name='test-inv', organization=organization)
|
inv = Inventory.objects.create(name='test-inv', organization=organization)
|
||||||
group = Group.objects.create(name='Test Group', inventory=inv)
|
group = Group.objects.create(name='Test Group', inventory=inv)
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ def test_associate_hosts_and_groups(run_module, admin_user, organization):
|
|||||||
name='Test Group',
|
name='Test Group',
|
||||||
inventory='test-inv',
|
inventory='test-inv',
|
||||||
hosts=[inv_hosts[1].name, inv_hosts[2].name],
|
hosts=[inv_hosts[1].name, inv_hosts[2].name],
|
||||||
groups=[child.name],
|
children=[child.name],
|
||||||
state='present'
|
state='present'
|
||||||
), admin_user)
|
), admin_user)
|
||||||
assert not result.get('failed', False), result.get('msg', result)
|
assert not result.get('failed', False), result.get('msg', result)
|
||||||
@@ -77,6 +77,23 @@ def test_associate_on_create(run_module, admin_user, organization):
|
|||||||
assert set(group.children.all()) == set([child])
|
assert set(group.children.all()) == set([child])
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_children_alias_of_groups(run_module, admin_user, organization):
|
||||||
|
inv = Inventory.objects.create(name='test-inv', organization=organization)
|
||||||
|
group = Group.objects.create(name='Test Group', inventory=inv)
|
||||||
|
child = Group.objects.create(inventory=inv, name='child_group')
|
||||||
|
result = run_module('tower_group', dict(
|
||||||
|
name='Test Group',
|
||||||
|
inventory='test-inv',
|
||||||
|
groups=[child.name],
|
||||||
|
state='present'
|
||||||
|
), admin_user)
|
||||||
|
assert not result.get('failed', False), result.get('msg', result)
|
||||||
|
assert result['changed'] is True
|
||||||
|
|
||||||
|
assert set(group.children.all()) == set([child])
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_tower_group_idempotent(run_module, admin_user):
|
def test_tower_group_idempotent(run_module, admin_user):
|
||||||
# https://github.com/ansible/ansible/issues/46803
|
# https://github.com/ansible/ansible/issues/46803
|
||||||
|
|||||||
Reference in New Issue
Block a user