Martin Kosek wrote:
On Wed, 2011-08-17 at 14:23 -0400, Rob Crittenden wrote:
Rob Crittenden wrote:
Let hostgroups show that they are members of netgroups.

rob

Updated patch

It works fine with CLI. Still, I have 2 remarks:

1) Although the new "netgroup" tab in the WebUI screen for Host Group
was displayed, Delete/Enroll actions in this new tab did not work. I did
not find any problem in CLI, maybe Endi or Petr can provide a hint what
is wrong.

2) This patch's needs to be rebased, there were conflicts in updated
tests.

So its ACK from me if the tests are fixed + WebUI guys don't object to
the patch.

Martin


Updated patch so Endi can give it a quick looksee

rob
>From 1deac2e5f6dcc21b7f128930ad5ccd32a7bfbd83 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Tue, 30 Aug 2011 14:08:34 -0400
Subject: [PATCH] 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 2929b9819b8533bf099eeddcadfc2741d1f2bb63..b7578b66f32b9abcdf74ad73b9d8287777f25202 100644
--- a/API.txt
+++ b/API.txt
@@ -1486,7 +1486,7 @@ output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly
 output: Output('result', <type 'dict'>, 'list of deletions that failed')
 output: Output('value', <type 'unicode'>, "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=<lambda>, 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 a316270fa0a0ae5090554b110c08cad92dd07c83..d75f381e0250c1709d1497db8fe9bac501f4a0be 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 e0d115854e1f437da04cae797eb67e4b82230850..6c3b0a41e93eb97bf56edb687bacd626f0888db0 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 cb2d1d0b29fefabb6eea4e4acd9c3ffe855db78e..31525cd261c7fef1a737947585c11a2305bfd32a 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 9194b549260a569ae777090a33d68b7e3339ead2..f28c667ac0a277f4c1191e19990e09554d5c0718 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)],
-- 
1.7.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to