mirror of
https://github.com/xcat2/confluent.git
synced 2026-12-01 14:52:20 +00:00
Provide a '-s' argument to let users skip sections they don't want in /etc/hosts.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
@@ -128,7 +128,14 @@ def main():
|
||||
ap.add_argument('-i', '--ip', help='Expression to generate addresses (e.g. 172.16.1.{n1} or fd2b:246f:8a50::{n1:x})')
|
||||
ap.add_argument('-n', '--name', help='Expression for name to add ({node}-compute, etc). If unspecified, "{node} {node}.{dns.domain}" will be used', action='append')
|
||||
ap.add_argument('-f', '--fqdn-first', help='Put the FQDN first in the hosts entries', action='store_true')
|
||||
ap.add_argument('-s', '--skip-nets', help='Network name(s) to skip when using -a, comma delimited, may be specified multiple times', action='append')
|
||||
args = ap.parse_args()
|
||||
skipnets = set()
|
||||
for skipent in args.skip_nets or ():
|
||||
skipnets.update(x.strip() for x in skipent.split(',') if x.strip())
|
||||
if skipnets and not args.attrib:
|
||||
sys.stderr.write('-s/--skip-nets requires -a/--attrib\n')
|
||||
sys.exit(1)
|
||||
c = client.Command()
|
||||
if args.name:
|
||||
names = ' '.join(args.name)
|
||||
@@ -172,6 +179,8 @@ def main():
|
||||
mydomain = domainsbynode.get(node, None)
|
||||
for ipdb in (ip4bynode, ip6bynode):
|
||||
for currnet in ipdb[node]:
|
||||
if currnet in skipnets:
|
||||
continue
|
||||
if args.name:
|
||||
sys.stderr.write('Custom name and attribute addresses not currently supported together\n')
|
||||
sys.exit(1)
|
||||
|
||||
@@ -13,7 +13,7 @@ noderange. There are two general approaches.
|
||||
|
||||
It can be used ad-hoc, using -i and -n to specify the address and name portions respectively. This accepts the standard confluent expression syntax, allowing for things like 172.30.1.{n1} or {node}.{dns.domain} or {bmc}.
|
||||
|
||||
It can also read from the confluent db, using `-a`. In this mode, each net.<value>.<attribute> group is pulled together into hosts lines. ipv4_address and ipv6_address fields are associated with the corresponding hostname attributes. You can use `-f` to put the FQDN first.
|
||||
It can also read from the confluent db, using `-a`. In this mode, each net.<value>.<attribute> group is pulled together into hosts lines. ipv4_address and ipv6_address fields are associated with the corresponding hostname attributes. You can use `-f` to put the FQDN first. Use `-s` to skip one or more named networks (the <value> in net.<value>.<attribute>); it accepts a comma delimited list and may be specified multiple times.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
@@ -26,3 +26,6 @@ It can also read from the confluent db, using `-a`. In this mode, each net.<val
|
||||
* Generate /etc/hosts entries using the confluent DB as a reference:
|
||||
`# confluent2hosts -a d9-d12`
|
||||
|
||||
* Generate /etc/hosts entries from the confluent DB, skipping the net.bmc and net.ib networks:
|
||||
`# confluent2hosts -a -s bmc,ib d9-d12`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user