diff options
author | Martin Basti <mbasti@redhat.com> | 2014-07-09 18:10:50 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2014-08-11 16:01:38 +0200 |
commit | ca001814abe533f19498d4207b5233eff17549a5 (patch) | |
tree | 251a20d701edcb14194751c8f704720f45845cfc | |
parent | 6bb240fa2cf6ce257376241d0a779ca5cc96078e (diff) | |
download | freeipa-ca001814abe533f19498d4207b5233eff17549a5.tar.gz freeipa-ca001814abe533f19498d4207b5233eff17549a5.tar.xz freeipa-ca001814abe533f19498d4207b5233eff17549a5.zip |
Allow to add host if AAAA record exists
http://fedorahosted.org/freeipa/ticket/4164
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
-rw-r--r-- | ipalib/errors.py | 6 | ||||
-rw-r--r-- | ipalib/util.py | 17 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_host_plugin.py | 2 |
3 files changed, 18 insertions, 7 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py index 09b7779e9..14e052990 100644 --- a/ipalib/errors.py +++ b/ipalib/errors.py @@ -1119,19 +1119,19 @@ class DefaultGroupError(ExecutionError): class DNSNotARecordError(ExecutionError): """ - **4019** Raised when a hostname is not a DNS A record + **4019** Raised when a hostname is not a DNS A/AAAA record For example: >>> raise DNSNotARecordError() Traceback (most recent call last): ... - DNSNotARecordError: Host does not have corresponding DNS A record + DNSNotARecordError: Host does not have corresponding DNS A/AAAA record """ errno = 4019 - format = _('Host does not have corresponding DNS A record') + format = _('Host does not have corresponding DNS A/AAAA record') class ManagedGroupError(ExecutionError): """ diff --git a/ipalib/util.py b/ipalib/util.py index ef759d8d1..55c90a992 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -96,19 +96,30 @@ def find_modules_in_dir(src_dir): def validate_host_dns(log, fqdn): """ - See if the hostname has a DNS A record. + See if the hostname has a DNS A/AAAA record. """ try: answers = resolver.query(fqdn, rdatatype.A) log.debug( - 'IPA: found %d records for %s: %s' % (len(answers), fqdn, + 'IPA: found %d A records for %s: %s' % (len(answers), fqdn, ' '.join(str(answer) for answer in answers)) ) except DNSException, e: log.debug( 'IPA: DNS A record lookup failed for %s' % fqdn ) - raise errors.DNSNotARecordError() + # A record not found, try to find AAAA record + try: + answers = resolver.query(fqdn, rdatatype.AAAA) + log.debug( + 'IPA: found %d AAAA records for %s: %s' % (len(answers), fqdn, + ' '.join(str(answer) for answer in answers)) + ) + except DNSException, e: + log.debug( + 'IPA: DNS AAAA record lookup failed for %s' % fqdn + ) + raise errors.DNSNotARecordError() def has_soa_or_ns_record(domain): diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py index 6a9e9f17c..725e8900f 100644 --- a/ipatests/test_xmlrpc/test_host_plugin.py +++ b/ipatests/test_xmlrpc/test_host_plugin.py @@ -684,7 +684,7 @@ class test_host(Declarative): desc='Try to add host not in DNS %r without force' % fqdn2, command=('host_add', [fqdn2], {}), expected=errors.DNSNotARecordError( - reason=u'Host does not have corresponding DNS A record'), + reason=u'Host does not have corresponding DNS A/AAAA record'), ), |