From e52f6528736f311e06c188e5b4858b6fc0ec16f0 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Tue, 30 Aug 2011 14:08:34 -0400 Subject: Add netgroup as possible memberOf for hostgroups https://fedorahosted.org/freeipa/ticket/1563 --- API.txt | 4 +++- ipalib/plugins/hostgroup.py | 2 +- tests/test_xmlrpc/test_hostgroup_plugin.py | 7 +++++++ tests/test_xmlrpc/test_nesting.py | 5 +++++ tests/test_xmlrpc/test_netgroup_plugin.py | 1 + 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/API.txt b/API.txt index 2929b9819..b7578b66f 100644 --- a/API.txt +++ b/API.txt @@ -1486,7 +1486,7 @@ output: Output('summary', (, ), 'User-friendly output: Output('result', , 'list of deletions that failed') output: Output('value', , "The primary_key value of the entry, e.g. 'jdoe' for a user") command: hostgroup_find -args: 1,17,4 +args: 1,19,4 arg: Str('criteria?', noextrawhitespace=False) option: Str('cn', attribute=True, autofill=False, cli_name='hostgroup_name', label=Gettext('Host-group', domain='ipa', localedir=None), multivalue=False, normalizer=, primary_key=True, query=True, required=False) option: Str('description', attribute=True, autofill=False, cli_name='desc', label=Gettext('Description', domain='ipa', localedir=None), multivalue=False, query=True, required=False) @@ -1501,6 +1501,8 @@ option: List('hostgroup?', cli_name='hostgroups', label=Gettext('host group', do option: List('no_hostgroup?', cli_name='no_hostgroups', label=Gettext('host group', domain='ipa', localedir=None), multivalue=True) option: List('in_hostgroup?', cli_name='in_hostgroups', label=Gettext('host group', domain='ipa', localedir=None), multivalue=True) option: List('not_in_hostgroup?', cli_name='not_in_hostgroups', label=Gettext('host group', domain='ipa', localedir=None), multivalue=True) +option: List('in_netgroup?', cli_name='in_netgroups', label=Gettext('netgroup', domain='ipa', localedir=None), multivalue=True) +option: List('not_in_netgroup?', cli_name='not_in_netgroups', label=Gettext('netgroup', domain='ipa', localedir=None), multivalue=True) option: List('in_hbacrule?', cli_name='in_hbacrules', label=Gettext('HBAC rule', domain='ipa', localedir=None), multivalue=True) option: List('not_in_hbacrule?', cli_name='not_in_hbacrules', label=Gettext('HBAC rule', domain='ipa', localedir=None), multivalue=True) option: List('in_sudorule?', cli_name='in_sudorules', label=Gettext('sudo rule', domain='ipa', localedir=None), multivalue=True) diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py index a316270fa..d75f381e0 100644 --- a/ipalib/plugins/hostgroup.py +++ b/ipalib/plugins/hostgroup.py @@ -65,7 +65,7 @@ class hostgroup(LDAPObject): uuid_attribute = 'ipauniqueid' attribute_members = { 'member': ['host', 'hostgroup'], - 'memberof': ['hostgroup', 'hbacrule', 'sudorule'], + 'memberof': ['hostgroup', 'netgroup', 'hbacrule', 'sudorule'], 'memberindirect': ['host', 'hostgroup'], 'memberofindirect': ['hostgroup', 'hbacrule', 'sudorule'], } diff --git a/tests/test_xmlrpc/test_hostgroup_plugin.py b/tests/test_xmlrpc/test_hostgroup_plugin.py index e0d115854..6c3b0a41e 100644 --- a/tests/test_xmlrpc/test_hostgroup_plugin.py +++ b/tests/test_xmlrpc/test_hostgroup_plugin.py @@ -83,6 +83,7 @@ class test_hostgroup(Declarative): objectclass=objectclasses.hostgroup, description=[u'Test hostgroup 1'], ipauniqueid=[fuzzy_uuid], + memberof_netgroup=[hostgroup1], mepmanagedentry=lambda x: [DN(i) for i in x] == \ [DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), api.env.basedn)], @@ -146,6 +147,7 @@ class test_hostgroup(Declarative): 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], 'member_host': [fqdn1], + 'memberof_netgroup': [hostgroup1], }, ), ), @@ -162,6 +164,7 @@ class test_hostgroup(Declarative): 'member_host': [u'testhost1.%s' % api.env.domain], 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], + 'memberof_netgroup': [hostgroup1], }, ), ), @@ -180,6 +183,7 @@ class test_hostgroup(Declarative): 'member_host': [u'testhost1.%s' % api.env.domain], 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], + 'memberof_netgroup': [hostgroup1], }, ], ), @@ -198,6 +202,7 @@ class test_hostgroup(Declarative): cn=[hostgroup1], description=[u'Updated hostgroup 1'], member_host=[u'testhost1.%s' % api.env.domain], + memberof_netgroup=[hostgroup1], ), ), ), @@ -214,6 +219,7 @@ class test_hostgroup(Declarative): 'member_host': [u'testhost1.%s' % api.env.domain], 'cn': [hostgroup1], 'description': [u'Updated hostgroup 1'], + 'memberof_netgroup': [hostgroup1], }, ), ), @@ -236,6 +242,7 @@ class test_hostgroup(Declarative): 'dn': lambda x: DN(x) == dn1, 'cn': [hostgroup1], 'description': [u'Updated hostgroup 1'], + 'memberof_netgroup': [hostgroup1], }, ), ), diff --git a/tests/test_xmlrpc/test_nesting.py b/tests/test_xmlrpc/test_nesting.py index cb2d1d0b2..31525cd26 100644 --- a/tests/test_xmlrpc/test_nesting.py +++ b/tests/test_xmlrpc/test_nesting.py @@ -705,6 +705,7 @@ class test_nesting(Declarative): objectclass=objectclasses.hostgroup, description=[u'Test hostgroup 1'], ipauniqueid=[fuzzy_uuid], + memberof_netgroup=[hostgroup1], mepmanagedentry=lambda x: [DN(i) for i in x] == \ [DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), api.env.basedn)], @@ -727,6 +728,7 @@ class test_nesting(Declarative): objectclass=objectclasses.hostgroup, description=[u'Test hostgroup 2'], ipauniqueid=[fuzzy_uuid], + memberof_netgroup=[hostgroup2], mepmanagedentry=lambda x: [DN(i) for i in x] == \ [DN(('cn',hostgroup2),('cn','ng'),('cn','alt'), api.env.basedn)], @@ -753,6 +755,7 @@ class test_nesting(Declarative): 'cn': [hostgroup2], 'description': [u'Test hostgroup 2'], 'member_host': [fqdn1], + 'memberof_netgroup': [hostgroup2], }, ), ), @@ -776,6 +779,7 @@ class test_nesting(Declarative): 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], 'member_hostgroup': [hostgroup2], + 'memberof_netgroup': [hostgroup1], }, ), ), @@ -791,6 +795,7 @@ class test_nesting(Declarative): 'dn': lambda x: DN(x) == hgdn1, 'memberindirect_host': [u'testhost1.%s' % api.env.domain], 'member_hostgroup': [hostgroup2], + 'memberof_netgroup': [hostgroup1], 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], }, diff --git a/tests/test_xmlrpc/test_netgroup_plugin.py b/tests/test_xmlrpc/test_netgroup_plugin.py index 9194b5492..f28c667ac 100644 --- a/tests/test_xmlrpc/test_netgroup_plugin.py +++ b/tests/test_xmlrpc/test_netgroup_plugin.py @@ -188,6 +188,7 @@ class test_netgroup(Declarative): cn=[hostgroup1], objectclass=objectclasses.hostgroup, description=[u'Test hostgroup 1'], + memberof_netgroup=[hostgroup1], mepmanagedentry=lambda x: [DN(i) for i in x] == \ [DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), api.env.basedn)], -- cgit