pvl.hosts-dns: ip6 support
authorTero Marttila <terom@paivola.fi>
Mon, 16 Dec 2013 20:50:04 +0200
changeset 283 951e4b70bad4
parent 282 63135113fe01
child 284 eb7e2a4c6880
pvl.hosts-dns: ip6 support
bin/pvl.hosts-dns
--- a/bin/pvl.hosts-dns	Mon Dec 16 20:49:50 2013 +0200
+++ b/bin/pvl.hosts-dns	Mon Dec 16 20:50:04 2013 +0200
@@ -45,13 +45,20 @@
     """
 
     for host in hosts :
-        if not host.ip :
+        if prefix.version == 4 :
+            ip = host.ip
+        elif prefix.version == 6 :
+            ip = host.ip6
+        else :
+            raise ValueError("%s: unknown ip version: %s" % (prefix, prefix.version))
+
+        if not ip :
             continue
 
-        if host.ip not in prefix :
+        if ip not in prefix :
             continue
 
-        yield host.ip, pvl.dns.zone.fqdn(host, host.domain)
+        yield ip, pvl.dns.zone.fqdn(host, host.domain)
  
 def process_hosts_reverse (options, hosts, prefix) :
     """