diff options
author | Rob Crittenden <rcritten@redhat.com> | 2010-10-27 12:07:53 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2010-10-28 17:47:20 -0400 |
commit | 3c795f3251bd0354d56e2b50042ee04cee7cd21f (patch) | |
tree | 2b52ddf89754c8375290343cdc51563c147346fd /ipalib/plugins/baseldap.py | |
parent | 7486ead6c910d13ae4d7cbae6fae738ce2bf47eb (diff) | |
download | freeipa.git-3c795f3251bd0354d56e2b50042ee04cee7cd21f.tar.gz freeipa.git-3c795f3251bd0354d56e2b50042ee04cee7cd21f.tar.xz freeipa.git-3c795f3251bd0354d56e2b50042ee04cee7cd21f.zip |
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
Diffstat (limited to 'ipalib/plugins/baseldap.py')
-rw-r--r-- | ipalib/plugins/baseldap.py | 26 |
1 files changed, 17 insertions, 9 deletions
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 |