diff options
author | Petr Spacek <pspacek@redhat.com> | 2016-05-17 17:20:25 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-05-30 20:14:32 +0200 |
commit | ec49130b94d2aa195c6b704a30fe6c3137fabdbf (patch) | |
tree | 4cfc49b4132079b2baab6edf7c73eeddcbac3aac | |
parent | 0c75df4bf3784eae08f41c176bbaab44c6d510a7 (diff) | |
download | freeipa-ec49130b94d2aa195c6b704a30fe6c3137fabdbf.tar.gz freeipa-ec49130b94d2aa195c6b704a30fe6c3137fabdbf.tar.xz freeipa-ec49130b94d2aa195c6b704a30fe6c3137fabdbf.zip |
Use root_logger for verify_host_resolvable()
After discussion with Martin Basti we decided to standardize on root_logger
with hope that one day we will use root_logger.getLogger('module')
to make logging prettier and tunable per module.
https://fedorahosted.org/freeipa/ticket/5710
Reviewed-By: Martin Basti <mbasti@redhat.com>
-rwxr-xr-x | client/ipa-client-install | 2 | ||||
-rwxr-xr-x | install/tools/ipa-replica-manage | 2 | ||||
-rw-r--r-- | ipalib/plugins/dns.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/host.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/service.py | 8 | ||||
-rw-r--r-- | ipalib/util.py | 8 | ||||
-rw-r--r-- | ipaserver/install/bindinstance.py | 2 | ||||
-rw-r--r-- | ipatests/test_integration/tasks.py | 2 |
8 files changed, 16 insertions, 14 deletions
diff --git a/client/ipa-client-install b/client/ipa-client-install index cff3fbfcd..538b6adee 100755 --- a/client/ipa-client-install +++ b/client/ipa-client-install @@ -1753,7 +1753,7 @@ def get_server_connection_interface(server): def client_dns(server, hostname, options): try: - verify_host_resolvable(hostname, root_logger) + verify_host_resolvable(hostname) dns_ok = True except errors.DNSNotARecordError: root_logger.warning("Hostname (%s) does not have A/AAAA record.", diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage index 14e768965..8e692d295 100755 --- a/install/tools/ipa-replica-manage +++ b/install/tools/ipa-replica-manage @@ -830,7 +830,7 @@ def enforce_host_existence(host, message=None): return try: - verify_host_resolvable(host, root_logger) + verify_host_resolvable(host) except errors.DNSNotARecordError as ex: if message is None: message = "Unknown host %s: %s" % (host, ex) diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index 72be52469..32319dc0f 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -1657,7 +1657,7 @@ def check_ns_rec_resolvable(zone, name, log): # this is a DNS name relative to the zone name = name.derelativize(zone.make_absolute()) try: - verify_host_resolvable(name, log) + verify_host_resolvable(name) except errors.DNSNotARecordError: raise errors.NotFound( reason=_('Nameserver \'%(host)s\' does not have a corresponding ' @@ -4286,7 +4286,7 @@ class dns_resolve(Command): query=args[0] try: - verify_host_resolvable(query, self.log) + verify_host_resolvable(query) except errors.DNSNotARecordError: raise errors.NotFound( reason=_('Host \'%(host)s\' not found') % {'host': query} diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index f15d5db2f..4cd08ebb2 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -633,7 +633,7 @@ class host_add(LDAPCreate): check_forward=True, check_reverse=check_reverse) if not options.get('force', False) and not 'ip_address' in options: - util.verify_host_resolvable(keys[-1], self.log) + util.verify_host_resolvable(keys[-1]) if 'locality' in entry_attrs: entry_attrs['l'] = entry_attrs['locality'] entry_attrs['cn'] = keys[-1] diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py index 4f03bd35f..2d3476e83 100644 --- a/ipalib/plugins/service.py +++ b/ipalib/plugins/service.py @@ -563,10 +563,10 @@ class service_add(LDAPCreate): entry_attrs['usercertificate'] = certs_der if not options.get('force', False): - # We know the host exists if we've gotten this far but we - # really want to discourage creating services for hosts that - # don't exist in DNS. - util.verify_host_resolvable(hostname, self.log) + # We know the host exists if we've gotten this far but we + # really want to discourage creating services for hosts that + # don't exist in DNS. + util.verify_host_resolvable(hostname) if not 'managedby' in entry_attrs: entry_attrs['managedby'] = hostresult['dn'] diff --git a/ipalib/util.py b/ipalib/util.py index 709bfbb8e..7d3a502e4 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -43,6 +43,7 @@ from ipapython.ssh import SSHPublicKey from ipapython.dn import DN, RDN from ipapython.dnsutil import DNSName from ipapython.graph import Graph +from ipapython.ipa_log_manager import root_logger if six.PY3: unicode = str @@ -64,7 +65,8 @@ def json_serialize(obj): return '' return json_serialize(obj.__json__()) -def verify_host_resolvable(fqdn, log): + +def verify_host_resolvable(fqdn): """ See if the hostname has a DNS A/AAAA record. """ @@ -75,12 +77,12 @@ def verify_host_resolvable(fqdn, log): for rdtype in ('A', 'AAAA'): try: answers = resolver.query(fqdn, rdtype) - log.debug( + root_logger.debug( 'IPA: found %d %s records for %s: %s' % (len(answers), rdtype, fqdn, ' '.join(str(answer) for answer in answers)) ) except DNSException: - log.debug( + root_logger.debug( 'IPA: DNS %s record lookup failed for %s' % (rdtype, fqdn) ) diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index 0a988562f..2a642422a 100644 --- a/ipaserver/install/bindinstance.py +++ b/ipaserver/install/bindinstance.py @@ -878,7 +878,7 @@ class BindInstance(service.Service): if not dns_zone_exists(zone, self.api): # check if master hostname is resolvable try: - verify_host_resolvable(fqdn, root_logger) + verify_host_resolvable(fqdn) except errors.DNSNotARecordError: root_logger.warning("Master FQDN (%s) is not resolvable.", fqdn) diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py index 70f4fa7fd..aebd907eb 100644 --- a/ipatests/test_integration/tasks.py +++ b/ipatests/test_integration/tasks.py @@ -1064,7 +1064,7 @@ def add_a_records_for_hosts_in_master_domain(master): # We don't need to take care of the zone creation since it is master # domain try: - verify_host_resolvable(host.hostname, log) + verify_host_resolvable(host.hostname) log.debug("The host (%s) is resolvable." % host.domain.name) except errors.DNSNotARecordError: log.debug("Hostname (%s) does not have A/AAAA record. Adding new one.", |