mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Allow to add host if AAAA record exists
http://fedorahosted.org/freeipa/ticket/4164 Reviewed-By: Petr Viktorin <pviktori@redhat.com>
This commit is contained in:
parent
6bb240fa2c
commit
ca001814ab
@ -1119,19 +1119,19 @@ class DefaultGroupError(ExecutionError):
|
|||||||
|
|
||||||
class DNSNotARecordError(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:
|
For example:
|
||||||
|
|
||||||
>>> raise DNSNotARecordError()
|
>>> raise DNSNotARecordError()
|
||||||
Traceback (most recent call last):
|
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
|
errno = 4019
|
||||||
format = _('Host does not have corresponding DNS A record')
|
format = _('Host does not have corresponding DNS A/AAAA record')
|
||||||
|
|
||||||
class ManagedGroupError(ExecutionError):
|
class ManagedGroupError(ExecutionError):
|
||||||
"""
|
"""
|
||||||
|
@ -96,18 +96,29 @@ def find_modules_in_dir(src_dir):
|
|||||||
|
|
||||||
def validate_host_dns(log, fqdn):
|
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:
|
try:
|
||||||
answers = resolver.query(fqdn, rdatatype.A)
|
answers = resolver.query(fqdn, rdatatype.A)
|
||||||
log.debug(
|
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))
|
' '.join(str(answer) for answer in answers))
|
||||||
)
|
)
|
||||||
except DNSException, e:
|
except DNSException, e:
|
||||||
log.debug(
|
log.debug(
|
||||||
'IPA: DNS A record lookup failed for %s' % fqdn
|
'IPA: DNS A record lookup failed for %s' % fqdn
|
||||||
)
|
)
|
||||||
|
# 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()
|
raise errors.DNSNotARecordError()
|
||||||
|
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ class test_host(Declarative):
|
|||||||
desc='Try to add host not in DNS %r without force' % fqdn2,
|
desc='Try to add host not in DNS %r without force' % fqdn2,
|
||||||
command=('host_add', [fqdn2], {}),
|
command=('host_add', [fqdn2], {}),
|
||||||
expected=errors.DNSNotARecordError(
|
expected=errors.DNSNotARecordError(
|
||||||
reason=u'Host does not have corresponding DNS A record'),
|
reason=u'Host does not have corresponding DNS A/AAAA record'),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user