diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-01-06 13:27:24 +0100 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2011-01-06 11:10:31 -0500 |
commit | 39a93612105ae7ed687ad4d0bf1320b1213fda9d (patch) | |
tree | bec467697532e52d5e2bb70e25bec8ec5e4d16eb /ipalib | |
parent | acb3ca0103d8c50c4674cc9912f42698bc801704 (diff) | |
download | freeipa-39a93612105ae7ed687ad4d0bf1320b1213fda9d.tar.gz freeipa-39a93612105ae7ed687ad4d0bf1320b1213fda9d.tar.xz freeipa-39a93612105ae7ed687ad4d0bf1320b1213fda9d.zip |
Handle error messages during Host operations
Only a generic error message were displayed when a non-existing
host was passed to host-del or host-disable operations.
This patch adds catching these generic exceptions and raising
new exceptions with the correct error message.
https://fedorahosted.org/freeipa/ticket/303
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugins/host.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index e24da1bf3..3b0b8eef4 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -456,7 +456,11 @@ class host_del(LDAPDelete): _attribute_types[attr], record[attr][i]) break - (dn, entry_attrs) = ldap.get_entry(dn, ['usercertificate']) + try: + (dn, entry_attrs) = ldap.get_entry(dn, ['usercertificate']) + except errors.NotFound: + self.obj.handle_not_found(*keys) + if 'usercertificate' in entry_attrs: cert = normalize_certificate(entry_attrs.get('usercertificate')[0]) try: @@ -651,7 +655,10 @@ class host_disable(LDAPQuery): done_work = False dn = self.obj.get_dn(*keys, **options) - (dn, entry_attrs) = ldap.get_entry(dn, ['krblastpwdchange', 'usercertificate']) + try: + (dn, entry_attrs) = ldap.get_entry(dn, ['krblastpwdchange', 'usercertificate']) + except errors.NotFound: + self.obj.handle_not_found(*keys) truncated = True while truncated: |