diff options
author | Rob Crittenden <rcritten@redhat.com> | 2010-10-29 11:32:03 -0400 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2010-10-29 14:03:15 -0400 |
commit | 03de1b89ca4be1c178ef044a912a30c4626a9917 (patch) | |
tree | 0a7b0ad367a07b38a1e3b023dcb0e72ccd6ee96f /ipalib/plugins | |
parent | 6df16f3a1007bb60414bda87c970a89b21713888 (diff) | |
download | freeipa-03de1b89ca4be1c178ef044a912a30c4626a9917.tar.gz freeipa-03de1b89ca4be1c178ef044a912a30c4626a9917.tar.xz freeipa-03de1b89ca4be1c178ef044a912a30c4626a9917.zip |
Implement nested netgroups and include summaries for the commands.
Replace the existing netgroup test cases with Declarative tests. This triples
the number of tests we were doing.
ticket 209
Diffstat (limited to 'ipalib/plugins')
-rw-r--r-- | ipalib/plugins/baseldap.py | 19 | ||||
-rw-r--r-- | ipalib/plugins/netgroup.py | 29 |
2 files changed, 38 insertions, 10 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index f3aa09d3e..97a02946b 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -199,14 +199,17 @@ class LDAPObject(Object): return parent_dn def get_primary_key_from_dn(self, dn): - if self.rdn_attribute: - (dn, entry_attrs) = self.backend.get_entry( - dn, [self.primary_key.name] - ) - try: - return entry_attrs[pkey][0] - except (KeyError, IndexError): - return '' + try: + if self.rdn_attribute: + (dn, entry_attrs) = self.backend.get_entry( + dn, [self.primary_key.name] + ) + try: + return entry_attrs[self.primary_key.name][0] + except (KeyError, IndexError): + return '' + except errors.NotFound: + pass return dn[len(self.primary_key.name) + 1:dn.find(',')] def get_ancestor_primary_keys(self): diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py index 28647b963..199b4868a 100644 --- a/ipalib/plugins/netgroup.py +++ b/ipalib/plugins/netgroup.py @@ -46,6 +46,21 @@ from ipalib.plugins.baseldap import * from ipalib import _, ngettext +output_params = ( + Str('memberuser_user?', + label='Member User', + ), + Str('memberuser_group?', + label='Member Group', + ), + Str('memberhost_host?', + label=_('Member Host'), + ), + Str('memberhost_hostgroup?', + label='Member Hostgroup', + ), + ) + class netgroup(LDAPObject): """ Netgroup object. @@ -56,7 +71,7 @@ class netgroup(LDAPObject): object_class = ['ipaobject', 'ipaassociation', 'ipanisnetgroup'] default_attributes = [ 'cn', 'description', 'memberof', 'externalhost', 'nisdomainname', - 'memberuser', 'memberhost','member', 'memberindirect', + 'memberuser', 'memberhost', 'member', 'memberindirect', ] uuid_attribute = 'ipauniqueid' rdn_attribute = 'ipauniqueid' @@ -101,6 +116,8 @@ class netgroup_add(LDAPCreate): """ Add a new netgroup. """ + has_output_params = LDAPCreate.has_output_params + output_params + msg_summary = _('Added netgroup "%(value)s"') def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): entry_attrs.setdefault('nisdomainname', self.api.env.domain) return dn @@ -121,6 +138,8 @@ class netgroup_mod(LDAPUpdate): """ Modify a netgroup. """ + has_output_params = LDAPUpdate.has_output_params + output_params + msg_summary = _('Modified netgroup "%(value)s"') api.register(netgroup_mod) @@ -129,6 +148,10 @@ class netgroup_find(LDAPSearch): """ Search for a netgroup. """ + has_output_params = LDAPSearch.has_output_params + output_params + msg_summary = ngettext( + '%(count)d netgroup matched', '%(count)d netgroups matched' + ) api.register(netgroup_find) @@ -146,6 +169,7 @@ class netgroup_add_member(LDAPAddMember): Add members to a netgroup. """ member_attributes = ['memberuser', 'memberhost', 'member'] + has_output_params = LDAPAddMember.has_output_params + output_params def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): completed_external = 0 # Sift through the host failures. We assume that these are all @@ -180,7 +204,8 @@ class netgroup_remove_member(LDAPRemoveMember): """ Remove members from a netgroup. """ - member_attributes = ['memberuser', 'memberhost'] + member_attributes = ['memberuser', 'memberhost', 'member'] + has_output_params = LDAPRemoveMember.has_output_params + output_params def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): # Run through the host failures and gracefully remove any defined as # as an externalhost. |