--- a/bin/pvl.hosts-dns Sat Dec 21 22:57:48 2013 +0200
+++ b/bin/pvl.hosts-dns Sun Dec 22 17:25:09 2013 +0200
@@ -42,7 +42,20 @@
fqdn = pvl.dns.join(host, host.domain)
label = fqdn[:(len(fqdn) - len(origin) - 1)]
else :
- log.debug("%s: %s out of zone: %s", host, host.domain, origin)
+ log.debug("%s: domain %s out of zone: %s", host, host.domain, origin)
+ continue
+
+ if host.forward is None :
+ pass
+ elif host.forward :
+ forward = pvl.dns.join(host, host.forward, host.domain)
+
+ log.info("%s: forward: %s", host, forward)
+
+ yield pvl.dns.zone.ZoneRecord.CNAME(label, forward)
+ continue
+ else :
+ log.info("%s: skip forward", host)
continue
if host.ip :
@@ -173,11 +186,26 @@
log.debug("%s: %s out of prefix: %s", host, ip, prefix)
continue
- fqdn = host.fqdn()
+ label = pvl.dns.zone.reverse_label(prefix, ip)
+
+ if host.reverse is None :
+ fqdn = host.fqdn()
- log.debug("%s: ip=%s domain=%s: %s", host, ip, host.domain, fqdn)
+ log.info("%s %s[%s]: PTR %s", host, prefix, ip, fqdn)
- yield ip, fqdn
+ yield host, ip, pvl.dns.zone.ZoneRecord.PTR(label, fqdn)
+
+ elif host.reverse :
+ alias = pvl.dns.join(label, host.reverse, host.domain)
+
+ log.info("%s %s[%s]: CNAME %s", host, prefix, ip, alias)
+
+ yield host, ip, pvl.dns.zone.ZoneRecord.CNAME(label, alias)
+
+ else :
+ log.info("%s %s[%s]: omit", host, prefix, ip)
+ continue
+
def process_hosts_reverse (options, hosts, prefix) :
"""
@@ -186,11 +214,11 @@
# collect data for records
by_ip = dict()
- for ip, fqdn in process_hosts_ips(options, hosts, prefix) :
+ for host, ip, rr in process_hosts_ips(options, hosts, prefix) :
if ip in by_ip :
- raise ValueError("%s: duplicate ip: %s: %s" % (fqdn, ip, by_ip[ip]))
+ raise ValueError("%s: duplicate ip: %s: %s" % (host, ip, by_ip[ip]))
else :
- by_ip[ip] = fqdn
+ by_ip[ip] = rr
if options.unknown_host :
# enumerate all of them
@@ -200,17 +228,16 @@
for ip in iter_ips :
if ip in by_ip :
- fqdn = by_ip[ip]
+ yield by_ip[ip]
elif options.unknown_host :
+ label = pvl.dns.zone.reverse_label(prefix, ip)
fqdn = pvl.dns.zone.fqdn(options.unknown_host, options.hosts_domain)
+
+ log.info("%s %s[%s]: unused PTR %s", options.unknown_host, ip, prefix, fqdn)
+
+ yield pvl.dns.zone.ZoneRecord.PTR(label, fqdn)
else :
- fqdn = None
-
- log.info("%s: %s", ip, fqdn)
-
- if fqdn :
- # reverse against the reverse-dns zone origin
- yield pvl.dns.zone.ZoneRecord.PTR(pvl.dns.zone.reverse_label(prefix, ip), fqdn)
+ continue
def apply_zone (options, zone) :
"""