--- a/bin/pvl.hosts-dns Thu Dec 19 19:30:23 2013 +0200
+++ b/bin/pvl.hosts-dns Thu Dec 19 19:30:35 2013 +0200
@@ -7,7 +7,7 @@
import fnmatch
import ipaddr
import logging; log = logging.getLogger('pvl.hosts-dns')
-import optparse
+import optparse
def process_hosts_alias (options, origin, host_domain, alias, host) :
"""
@@ -68,18 +68,21 @@
for alias6 in host.alias6 :
yield process_hosts_alias(options, origin, host.domain, alias6, host.ALIAS6_FMT.format(host=label))
-def process_hosts_forward (options, hosts, domain) :
+def process_hosts_forward (options, hosts, origin) :
"""
- Generate DNS ZoneRecords for the given domain's zone for hosts.
+ Generate DNS ZoneRecords for for hosts within the given zone origin.
"""
+ if options.add_origin :
+ yield pvl.dns.zone.ZoneDirective.build(None, 'ORIGIN', origin)
+
by_name = dict()
by_name_type = dict()
# list of types thare are allowed to be present for a host
MULTI_TYPES = ('A', 'AAAA')
- for rr in process_hosts_names(options, hosts, domain) :
+ for rr in process_hosts_names(options, hosts, origin) :
if (rr.name, rr.type) in by_name_type :
raise ValueError("%s: duplicate name/type: %s: %s" % (rr.name, rr, by_name_type[(rr.name, rr.type)]))
elif rr.type in MULTI_TYPES :
@@ -228,6 +231,9 @@
parser.add_option_group(pvl.args.parser(parser))
parser.add_option_group(pvl.hosts.optparser(parser))
+ parser.add_option('--add-origin', action='store_true',
+ help="Include $ORIGIN directive in zone")
+
parser.add_option('--forward-zone', metavar='DOMAIN',
help="Generate forward zone for domain")