# HG changeset patch # User Tero Marttila # Date 1387218332 -7200 # Node ID 1b72f1e0cdbe38c51644aaf5865d27094b699785 # Parent 2db1a5323f9226f8bb58e7d379c3f309971e1dc8 pvl.hosts-import: do not import $GENERATE hosts; fix warnings on missing owner comments diff -r 2db1a5323f92 -r 1b72f1e0cdbe bin/pvl.hosts-import --- a/bin/pvl.hosts-import Mon Dec 16 20:21:30 2013 +0200 +++ b/bin/pvl.hosts-import Mon Dec 16 20:25:32 2013 +0200 @@ -91,7 +91,10 @@ Yield host info from zonefile records. """ - for rr in pvl.dns.zone.ZoneRecord.load(file) : + for rr in pvl.dns.zone.ZoneRecord.load(file, + # generated hosts need to imported by hand... + expand_generate = False, + ) : if options.zone_unused and rr.name == options.zone_unused : log.debug("%s: skip %s", rr.name, rr) continue @@ -221,10 +224,12 @@ if match : matches = match.groupdict() + + log.info("%s: matched comment: %s", hostname, comment) break else : if options.zone_comments_default : - log.warn("%s: default comment: %s", hostname, comment) + log.info("%s: default comment: %s", hostname, comment) matches = { options.zone_comments_default: comment } else : log.warn("%s: unknown comment: %s", hostname, comment) @@ -327,7 +332,7 @@ yield 'comment-owner', comment yield 'owner', owner, - else : + elif 'group' in info or 'owner' in info : log.warn("%s: unknown owner: %s", host, info) yield 'comment-owner', "{group} / {owner}".format( group = info.get('group', ''), diff -r 2db1a5323f92 -r 1b72f1e0cdbe pvl/dns/zone.py --- a/pvl/dns/zone.py Mon Dec 16 20:21:30 2013 +0200 +++ b/pvl/dns/zone.py Mon Dec 16 20:25:32 2013 +0200 @@ -162,7 +162,7 @@ data = None # list of data fields @classmethod - def load (cls, file, ttl=None, origin=None, **opts) : + def load (cls, file, ttl=None, origin=None, expand_generate=True, **opts) : """ Parse ZoneRecord items from the given zonefile, ignoring non-record lines. """ @@ -190,11 +190,14 @@ log.info("%s: ttl: %s", line, ttl) elif directive == 'GENERATE' : - # process... - log.info("%s: generate: %s", line, args) + if expand_generate : + # process... + log.info("%s: generate: %s", line, args) - for record in process_generate(line, origin, args) : - yield record + for record in process_generate(line, origin, args) : + yield record + else : + log.warn("%s: skip generate: %s", line, args) elif directive == 'INCLUDE' : include, = args