equal
deleted
inserted
replaced
1 #!/usr/bin/env python |
1 #!/usr/bin/env python |
2 |
2 |
|
3 import logging; log = logging.getLogger('pvl.hosts-forward') |
|
4 import optparse |
|
5 import pvl.args |
|
6 import pvl.hosts |
3 import pvl.hosts.zone |
7 import pvl.hosts.zone |
4 import sys |
|
5 |
8 |
6 sys.exit(pvl.hosts.zone.forward_main()) |
9 def main (argv): |
|
10 """ |
|
11 Generate bind zonefiles from host definitions. |
|
12 """ |
|
13 |
|
14 parser = optparse.OptionParser(main.__doc__) |
|
15 parser.add_option_group(pvl.args.parser(parser)) |
|
16 parser.add_option_group(pvl.hosts.config.optparser(parser)) |
|
17 |
|
18 parser.add_option('--forward-zone', metavar='DOMAIN', |
|
19 help="Generate forward zone for domain") |
|
20 |
|
21 parser.add_option('--add-origin', action='store_true', |
|
22 help="Include $ORIGIN directive in zone") |
|
23 |
|
24 # input |
|
25 options, args = pvl.args.parse(parser, argv) |
|
26 |
|
27 if not options.forward_zone: |
|
28 log.fatal("required --forward-zone") |
|
29 return 1 |
|
30 |
|
31 hosts = pvl.hosts.apply(options, args) |
|
32 |
|
33 # process |
|
34 for rr in pvl.hosts.zone.apply_hosts_forward(options, hosts, options.forward_zone): |
|
35 print unicode(rr) |
|
36 |
|
37 return 0 |
|
38 |
|
39 if __name__ == '__main__': |
|
40 pvl.args.main(main) |