diff options
| author | Abhijeet Kasurde <akasurde@redhat.com> | 2015-10-27 17:21:17 +0530 |
|---|---|---|
| committer | Martin Basti <mbasti@redhat.com> | 2015-10-29 13:41:41 +0100 |
| commit | c60cec4fa7adf004d383b68b78f6fd51d5cecb21 (patch) | |
| tree | f3b0039fb2b17cae5e7dc62ad0528d1cecc6ae45 | |
| parent | 82fd4250b9b4f408174edec7c7f070dc9fc73ab0 (diff) | |
Added user friendly error message for dnszone enable and disable
Added try-except block in dns plugin in order to provide user
friendly message to end user.
https://fedorahosted.org/freeipa/ticket/4811
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
| -rw-r--r-- | ipalib/plugins/dns.py | 12 | ||||
| -rw-r--r-- | ipatests/test_xmlrpc/test_dns_plugin.py | 8 |
2 files changed, 16 insertions, 4 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index ef282c946..48d6f740e 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -2231,7 +2231,11 @@ class DNSZoneBase_disable(LDAPQuery): ldap = self.obj.backend dn = self.obj.get_dn(*keys, **options) - entry = ldap.get_entry(dn, ['idnszoneactive', 'objectclass']) + try: + entry = ldap.get_entry(dn, ['idnszoneactive', 'objectclass']) + except errors.NotFound: + self.obj.handle_not_found(*keys) + if not _check_entry_objectclass(entry, self.obj.object_class): self.obj.handle_not_found(*keys) @@ -2252,7 +2256,11 @@ class DNSZoneBase_enable(LDAPQuery): ldap = self.obj.backend dn = self.obj.get_dn(*keys, **options) - entry = ldap.get_entry(dn, ['idnszoneactive', 'objectclass']) + try: + entry = ldap.get_entry(dn, ['idnszoneactive', 'objectclass']) + except errors.NotFound: + self.obj.handle_not_found(*keys) + if not _check_entry_objectclass(entry, self.obj.object_class): self.obj.handle_not_found(*keys) diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py index f0b8edaa1..e5d1374d0 100644 --- a/ipatests/test_xmlrpc/test_dns_plugin.py +++ b/ipatests/test_xmlrpc/test_dns_plugin.py @@ -4319,7 +4319,9 @@ class test_forward_zones(Declarative): dict( desc='Try to disable non-existent forward zone', command=('dnsforwardzone_disable', [nonexistent_fwzone], {}), - expected=errors.NotFound(reason="no such entry") + expected=errors.NotFound( + reason=u'%s: DNS forward zone not found' % nonexistent_fwzone + ) ), @@ -4364,7 +4366,9 @@ class test_forward_zones(Declarative): dict( desc='Try to enable non-existent forward zone', command=('dnsforwardzone_enable', [nonexistent_fwzone], {}), - expected=errors.NotFound(reason="no such entry") + expected=errors.NotFound( + reason=u'%s: DNS forward zone not found' % nonexistent_fwzone + ) ), ] |
