URL: https://github.com/freeipa/freeipa/pull/862
Author: Tiboris
 Title: #862: dnsserver.py: dnsserver-find no longer returns internal server 
error
Action: opened

PR body:
"""
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
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/862/head:pr862
git checkout pr862
From 4b41c88a2538c509b9d8b7fbecfe35342180e252 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tibor=20Dudl=C3=A1k?= <tdud...@redhat.com>
Date: Wed, 7 Jun 2017 17:03:20 +0200
Subject: [PATCH] dnsserver.py: dnsserver-find 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
---
 ipaserver/plugins/dnsserver.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ipaserver/plugins/dnsserver.py b/ipaserver/plugins/dnsserver.py
index d635722a6b..49bd6cf1a1 100644
--- a/ipaserver/plugins/dnsserver.py
+++ b/ipaserver/plugins/dnsserver.py
@@ -29,6 +29,7 @@
     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):
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to