summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2015-07-01 17:40:16 +0200
committerTomas Babej <tbabej@redhat.com>2015-07-01 20:19:01 +0200
commit96c23659fcb8adc64dd925556fb40f558fa7e37d (patch)
tree4b10837e02fc14c6b84e363dd736f9d39bbcb89f
parent25a5e38b85f897cc798609217830b626b7880da1 (diff)
downloadfreeipa-96c23659fcb8adc64dd925556fb40f558fa7e37d.zip
freeipa-96c23659fcb8adc64dd925556fb40f558fa7e37d.tar.gz
freeipa-96c23659fcb8adc64dd925556fb40f558fa7e37d.tar.xz
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 Reviewed-By: Tomas Babej <tbabej@redhat.com>
-rw-r--r--ipalib/plugins/dns.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index f65f8f4..a7a4100 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):