From 39a93612105ae7ed687ad4d0bf1320b1213fda9d Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Thu, 6 Jan 2011 13:27:24 +0100 Subject: 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 --- ipalib/plugins/host.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ipalib') 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: -- cgit