https://fedorahosted.org/freeipa/ticket/5017
Patch attached -- Martin Basti
From b7ebb0661ff46306f25c5406ebaf0719e10e3834 Mon Sep 17 00:00:00 2001 From: Martin Basti <mba...@redhat.com> Date: Wed, 1 Jul 2015 17:40:16 +0200 Subject: [PATCH] DNS: Do not traceback if DNS is not installed Instead of internal error show 'DNS is not configured' message, when a dns* command is executed. https://fedorahosted.org/freeipa/ticket/5017 --- ipalib/plugins/dns.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index f65f8f4103547aa0a6b06de55129ef7fb47426e4..a7a4100db6de1956b8d0468e03214abc227386d5 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -2021,6 +2021,9 @@ class DNSZoneBase(LDAPObject): ) def get_dn(self, *keys, **options): + if not dns_container_exists(self.api.Backend.ldap2): + raise errors.NotFound(reason=_('DNS is not configured')) + zone = keys[-1] assert isinstance(zone, DNSName) assert zone.is_absolute() @@ -2101,8 +2104,6 @@ class DNSZoneBase_add(LDAPCreate): def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): assert isinstance(dn, DN) - if not dns_container_exists(self.api.Backend.ldap2): - raise errors.NotFound(reason=_('DNS is not configured')) try: entry = ldap.get_entry(dn) @@ -2177,6 +2178,9 @@ class DNSZoneBase_find(LDAPSearch): def pre_callback(self, ldap, filter, attrs_list, base_dn, scope, *args, **options): assert isinstance(base_dn, DN) + # Check if DNS container exists must be here for find methods + if not dns_container_exists(self.api.Backend.ldap2): + raise errors.NotFound(reason=_('DNS is not configured')) filter = _create_idn_filter(self, ldap, *args, **options) return (filter, base_dn, scope) @@ -3087,6 +3091,9 @@ class dnsrecord(LDAPObject): def get_dn(self, *keys, **options): + if not dns_container_exists(self.api.Backend.ldap2): + raise errors.NotFound(reason=_('DNS is not configured')) + dn = self.check_zone(keys[-2], **options) if self.is_pkey_zone_record(*keys): @@ -4249,6 +4256,8 @@ class dnsconfig(LDAPObject): } def get_dn(self, *keys, **kwargs): + if not dns_container_exists(self.api.Backend.ldap2): + raise errors.NotFound(reason=_('DNS is not configured')) return DN(api.env.container_dns, api.env.basedn) def get_dnsconfig(self, ldap): -- 2.4.3
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code