dnsserver.py: dnsserver-find no longer returns internal server error

Invocation of the ipa dnsserver-find command failed with
internal server error when there is no DNS server in topology.

Fixes: https://pagure.io/freeipa/issue/6571
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Tibor Dudlák
2017-06-07 17:03:20 +02:00
committed by Martin Basti
parent 440c61dc40
commit 74d36a8af6

View File

@@ -29,6 +29,7 @@ from ipaserver.plugins.baseldap import (
LDAPDelete,
)
from .dns import dns_container_exists
from ipapython.dn import DN
__doc__ = _("""
@@ -166,6 +167,16 @@ class dnsserver_find(LDAPSearch):
'%(count)d DNS servers matched', 0
)
def pre_callback(self, ldap, filters, attrs_list,
base_dn, scope, *args, **options):
assert isinstance(base_dn, DN)
if not dns_container_exists(self.api.Backend.ldap2):
raise errors.InvocationError(
format=_('IPA DNS Server is not installed'))
return (filters, base_dn, scope)
@register()
class dnsserver_show(LDAPRetrieve):