equal
deleted
inserted
replaced
79 parser.add_option('--output-prefix', metavar='PREFIX', |
79 parser.add_option('--output-prefix', metavar='PREFIX', |
80 help="Select hosts by ip prefix") |
80 help="Select hosts by ip prefix") |
81 |
81 |
82 parser.add_option('--output-domain', metavar='DOMAIN', |
82 parser.add_option('--output-domain', metavar='DOMAIN', |
83 help="Select hosts by domain") |
83 help="Select hosts by domain") |
|
84 |
|
85 parser.add_option('--output-others', action='store_true', |
|
86 help="Negate selection") |
84 |
87 |
85 # defaults |
88 # defaults |
86 parser.set_defaults( |
89 parser.set_defaults( |
87 import_zone_hosts = [], |
90 import_zone_hosts = [], |
88 import_dhcp_hosts = [], |
91 import_dhcp_hosts = [], |
657 else : |
660 else : |
658 # fake, to sort correctly |
661 # fake, to sort correctly |
659 sort = ipaddr.IPAddress(0) |
662 sort = ipaddr.IPAddress(0) |
660 |
663 |
661 # select |
664 # select |
|
665 match = True |
|
666 |
662 if prefix: |
667 if prefix: |
663 if not (ip and ip in prefix) : |
668 if not (ip and ip in prefix) : |
664 continue |
669 match = False |
665 |
670 |
666 if select_domain : |
671 if select_domain : |
667 if not (domain and domain == select_domain) : |
672 if not (domain and domain == select_domain) : |
668 continue |
673 match = False |
669 |
674 |
670 yield (domain, sort), (host, domain), fields |
675 if match and options.output_others : |
|
676 pass |
|
677 elif not match and not options.output_others : |
|
678 pass |
|
679 else : |
|
680 yield (domain, sort), (host, domain), fields |
671 |
681 |
672 def export_hosts (options, hosts) : |
682 def export_hosts (options, hosts) : |
673 """ |
683 """ |
674 Generate hosts config lines for given hosts. |
684 Generate hosts config lines for given hosts. |
675 """ |
685 """ |