From 3c795f3251bd0354d56e2b50042ee04cee7cd21f Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 27 Oct 2010 12:07:53 -0400 Subject: Return reason for failure when updating group membership fails. We used to return a list of dns that failed to be added. We now return a list of tuples instead. The tuple looks like (dn, reason) where reason is the exception that was returned. Also made the label we use for failures to be singular instead of plural since we now print them out individually instead of as comma-separated. ticket 270 --- ipalib/plugins/baseldap.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'ipalib/plugins/baseldap.py') diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index f764efbb..f3aa09d3 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -117,6 +117,12 @@ global_output_params = ( Str('externalhost?', label=_('External host'), ), + Str('memberhost', + label=_('Failed hosts/hostgroups'), + ), + Str('memberuser', + label=_('Failed users/groups'), + ), ) @@ -818,7 +824,7 @@ class LDAPModMember(LDAPQuery): 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, - label=ldap_obj.object_name_plural) + label=ldap_obj.object_name) def get_member_dns(self, **options): dns = {} @@ -835,8 +841,8 @@ class LDAPModMember(LDAPQuery): ldap_obj = self.api.Object[ldap_obj_name] try: dns[attr][ldap_obj_name].append(ldap_obj.get_dn(name)) - except errors.PublicError: - failed[attr][ldap_obj_name].append(name) + except errors.PublicError, e: + failed[attr][ldap_obj_name].append((name, unicode(e))) return (dns, failed) @@ -884,10 +890,11 @@ class LDAPAddMember(LDAPModMember): continue try: ldap.add_entry_to_group(m_dn, dn, attr) - except errors.PublicError: + except errors.PublicError, e: ldap_obj = self.api.Object[ldap_obj_name] - failed[attr][ldap_obj_name].append( - ldap_obj.get_primary_key_from_dn(m_dn) + failed[attr][ldap_obj_name].append(( + ldap_obj.get_primary_key_from_dn(m_dn), + unicode(e),) ) else: completed += 1 @@ -985,10 +992,11 @@ class LDAPRemoveMember(LDAPModMember): continue try: ldap.remove_entry_from_group(m_dn, dn, attr) - except errors.PublicError: + except errors.PublicError, e: ldap_obj = self.api.Object[ldap_obj_name] - failed[attr][ldap_obj_name].append( - ldap_obj.get_primary_key_from_dn(m_dn) + failed[attr][ldap_obj_name].append(( + ldap_obj.get_primary_key_from_dn(m_dn), + unicode(e),) ) else: completed += 1 -- cgit