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>
This commit is contained in:
Abhijeet Kasurde 2015-10-27 17:21:17 +05:30 committed by Martin Basti
parent 82fd4250b9
commit c60cec4fa7
2 changed files with 16 additions and 4 deletions

View File

@ -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)

View File

@ -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
)
),
]