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
>From 8e1db8fa88fa16226055e69b9dade832e94eae9e Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Thu, 6 Jan 2011 13:27:24 +0100
Subject: [PATCH] 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 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index e24da1bf3cacba9a20f56d25a05fab2344243940..3b0b8eef453e6e08f40bd4f2d15fa7ab0c5cf404 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:
-- 
1.7.3.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to