Re: [Freeipa-devel] [PATCH 0101] Allow to add host if AAAA record exists

2014-07-28 Thread Petr Viktorin

On 07/09/2014 06:29 PM, Martin Basti wrote:

Patch attached.
Ticket: https://fedorahosted.org/freeipa/ticket/4164



Looks & works fine for me.
Can you also add a test for this?


--
PetrĀ³

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH 0101] Allow to add host if AAAA record exists

2014-07-09 Thread Martin Basti

Patch attached.
Ticket: https://fedorahosted.org/freeipa/ticket/4164
From 20d58a4d9868555dd74c9e2731c2b5d02c7afab8 Mon Sep 17 00:00:00 2001
From: Martin Basti 
Date: Wed, 9 Jul 2014 18:10:50 +0200
Subject: [PATCH] Allow to add host if  record exists

http://fedorahosted.org/freeipa/ticket/4164
---
 ipalib/errors.py |  6 +++---
 ipalib/util.py   | 17 ++---
 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 d69e33062c86c9338e18ca43cd4fbe842eabe016..77cb08f6e561c1fdd013f3031fbd11268ee7cb61 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -1113,19 +1113,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/ 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/ record
 
 """
 
 errno = 4019
-format = _('Host does not have corresponding DNS A record')
+format = _('Host does not have corresponding DNS A/ record')
 
 class ManagedGroupError(ExecutionError):
 """
diff --git a/ipalib/util.py b/ipalib/util.py
index ef759d8d108a61710f70f2a34ed5e10df3abe320..55c90a99208844386193ceef431b51651bfe2467 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/ 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  record
+try:
+answers = resolver.query(fqdn, rdatatype.)
+log.debug(
+'IPA: found %d  records for %s: %s' % (len(answers), fqdn,
+' '.join(str(answer) for answer in answers))
+)
+except DNSException, e:
+log.debug(
+'IPA: DNS  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 6a9e9f17c231ed4bb957b1edafebbf4e95029b40..725e8900fdd1eca2a0cda9fd88dc4e479970e62e 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/ record'),
 ),
 
 
-- 
1.8.3.1

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel