From 8ad88b411921ba90bdd149eb278639e1cbbe1a1a Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 2 Aug 2010 18:10:01 -0400 Subject: Properly show the members when an add/remove operation fails. The remove member function in baseldap was not returning failures at all. The add member function was only showing them in the group object. Most of the magic is handled in baseldap. Each plugin just needs to define object_name and object_name_plural. object_name must be all lower-case because fake-attributes are created so membership can be broken out per-object type. I left the plural name lower case as well. ticket 85 --- ipalib/plugins/baseldap.py | 21 +++++++++++++++++---- ipalib/plugins/group.py | 12 ------------ ipalib/plugins/hostgroup.py | 2 +- ipalib/plugins/netgroup.py | 4 ++-- 4 files changed, 20 insertions(+), 19 deletions(-) (limited to 'ipalib/plugins') diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 2b0ff2d73..11fd18ee9 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -569,7 +569,8 @@ class LDAPModMember(LDAPQuery): ldap_obj = self.api.Object[ldap_obj_name] name = to_cli(ldap_obj_name) doc = self.member_param_doc % ldap_obj.object_name_plural - yield List('%s?' % name, cli_name='%ss' % name, doc=doc) + yield List('%s?' % name, cli_name='%ss' % name, doc=doc, + label=ldap_obj.object_name_plural) def get_member_dns(self, **options): dns = {} @@ -610,6 +611,12 @@ class LDAPAddMember(LDAPModMember): ), ) + has_output_params = ( + Str('member', + label=_('Failed members'), + ), + ) + def execute(self, *keys, **options): ldap = self.obj.backend @@ -699,13 +706,19 @@ class LDAPRemoveMember(LDAPModMember): has_output = ( output.Entry('result'), + output.Output('failed', + type=dict, + doc=_('Members that could not be removed'), + ), output.Output('completed', type=int, doc=_('Number of members removed'), ), - output.Output('failed', - type=dict, - doc=_('Members that could not be removed'), + ) + + has_output_params = ( + Str('member', + label=_('Failed members'), ), ) diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py index 4fd630d42..f0e9f7724 100644 --- a/ipalib/plugins/group.py +++ b/ipalib/plugins/group.py @@ -115,18 +115,6 @@ class group(LDAPObject): label=_('Member users'), flags=['no_create', 'no_update', 'no_search'], ), - Str('member?', - label=_('Failed members'), - flags=['no_create', 'no_update', 'no_search'], - ), - Str('user?', - label=_('Users'), - flags=['no_create', 'no_update', 'no_search'], - ), - Str('group?', - label=_('Groups'), - flags=['no_create', 'no_update', 'no_search'], - ), ) api.register(group) diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py index fe5bed76b..ff97a1394 100644 --- a/ipalib/plugins/hostgroup.py +++ b/ipalib/plugins/hostgroup.py @@ -51,7 +51,7 @@ class hostgroup(LDAPObject): """ container_dn = api.env.container_hostgroup object_name = 'hostgroup' - object_name_plurals = 'hostgroups' + object_name_plural = 'hostgroups' object_class = ['ipaobject', 'ipahostgroup'] default_attributes = ['cn', 'description', 'member', 'memberof'] uuid_attribute = 'ipauniqueid' diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py index 755c5f4da..d2ffc404e 100644 --- a/ipalib/plugins/netgroup.py +++ b/ipalib/plugins/netgroup.py @@ -186,7 +186,7 @@ class netgroup_add_member(LDAPAddMember): """ Add members to netgroup. """ - has_output_params = output_params + has_output_params = LDAPAddMember.has_output_params + output_params member_attributes = ['memberuser', 'memberhost'] def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): completed_external = 0 @@ -222,7 +222,7 @@ class netgroup_remove_member(LDAPRemoveMember): """ Remove members from netgroup. """ - has_output_params = output_params + has_output_params = LDAPRemoveMember.has_output_params + output_params member_attributes = ['memberuser', 'memberhost'] def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): # Run through the host failures and gracefully remove any defined as -- cgit