pvl.hosts: handle fqdn hosts correctly as not having a domain
authorTero Marttila <terom@paivola.fi>
Sun, 22 Dec 2013 19:21:00 +0200
changeset 337 23b3c0661189
parent 336 edaa5d0aa57d
child 338 9198e2da360e
pvl.hosts: handle fqdn hosts correctly as not having a domain
bin/pvl.hosts-dns
pvl/hosts.py
--- a/bin/pvl.hosts-dns	Sun Dec 22 19:03:57 2013 +0200
+++ b/bin/pvl.hosts-dns	Sun Dec 22 19:21:00 2013 +0200
@@ -38,11 +38,14 @@
             label = pvl.dns.join(host, host.domain)
         elif host.domain == origin :
             label = str(host)
-        elif host.domain.endswith('.' + origin) :
+        elif host.domain and host.domain.endswith('.' + origin) :
             fqdn = pvl.dns.join(host, host.domain)
             label = fqdn[:(len(fqdn) - len(origin) - 1)]
+        elif host.domain :
+            log.debug("%s: domain %s out of zone: %s", host, host.domain, origin)
+            continue
         else :
-            log.debug("%s: domain %s out of zone: %s", host, host.domain, origin)
+            log.debug("%s: fqdn out of zone: %s", host, origin)
             continue
         
         if host.forward is None  :
--- a/pvl/hosts.py	Sun Dec 22 19:03:57 2013 +0200
+++ b/pvl/hosts.py	Sun Dec 22 19:21:00 2013 +0200
@@ -60,15 +60,15 @@
 
         if domain :
             log.debug("%s: explicit domain: %s", host, domain)
+        elif '.' in host :
+            log.debug("%s: using as fqdn without domain", host)
+            domain = None
         elif options.hosts_domain :
             log.debug("%s: default domain to --hots-domain: %s", host, options.hosts_domain)
             domain = options.hosts_domain
         elif section :
             log.debug("%s: default domain to section: %s", host, section)
             domain = section
-        elif '.' in host :
-            log.debug("%s: using as fqdn without domain", host)
-            domain = None
         else :
             raise ValueError("%s: no domain given" % (host, ))