diff --git a/src/hostinfo.py b/src/hostinfo.py index 731d10bb0070f317a44160e1cc973e4d389a446e..570c6f757edd31f12ec41a967482d33ed7a24898 100755 --- a/src/hostinfo.py +++ b/src/hostinfo.py @@ -203,7 +203,10 @@ if __name__ == '__main__': help="generate samba share FILE") optParser.add_option("--yp", action="store", metavar="DIR", - help="generate DIR/{hosts,ethers} information") + help="generate DIR/{hosts,ethers,etc} information") + optParser.add_option("--yp_auto_domain", + action="store", metavar="DOMAIN", + help="DOMAIN name for yp automounter maps") (options, args) = optParser.parse_args(sys.argv[1:]) @@ -258,7 +261,7 @@ if __name__ == '__main__': if options.yp: - for (f, c) in hostinfo.yp.generate(tree): + for (f, c) in hostinfo.yp.generate(tree, options.yp_auto_domain): file["%s/%s" % (options.yp, f)] = c if options.samba: diff --git a/src/hostinfo/ifconfig.py b/src/hostinfo/ifconfig.py index 49d5e65f7a057bcfbd8aa17846e0885858d6754b..4eef92b94af4c8ccefbcc35d447a0e2b6bc50d9c 100755 --- a/src/hostinfo/ifconfig.py +++ b/src/hostinfo/ifconfig.py @@ -47,6 +47,9 @@ def generate(tree, host): config += "DOMAIN=%s\n" % s.domain[0] else: config += "BOOTPROTO=dhcp\n" + if i.defroute[0]: + config += "DEFROUTE=%s\n" % i.defroute[0] + result.append(("ifcfg-%s" % d, config)) # Aliases and VLANs diff --git a/src/hostinfo/yp.py b/src/hostinfo/yp.py index 6f3c8ca2b6e75bdd3c7de4eb64591cc16cff950d..25ddf6c3f56a278e98b5b1161ae82a99fdcabb17 100755 --- a/src/hostinfo/yp.py +++ b/src/hostinfo/yp.py @@ -1,12 +1,12 @@ from hostinfo.util import fqn, aton, ntoa -def generate(tree): +def generate(tree, auto_domain): result = [] result.append(("hosts", hosts(tree))) result.append(("ethers", ethers(tree))) result.append(("netgroup", netgroup(tree))) - result.append(("auto.home", auto_map(tree, 'auto.home'))) - result.append(("auto.work", auto_map(tree, 'auto.work'))) + result.append(("auto.home", auto_map(tree, 'auto.home', auto_domain))) + result.append(("auto.work", auto_map(tree, 'auto.work', auto_domain))) return result def ypsuffix(tree, ip): @@ -122,14 +122,17 @@ def netgroup(tree): result += "\n" return result -def auto_map(tree, map_name): +def auto_map(tree, map_name, auto_domain): auto = {} for h in tree._host_: for a in h._automount_: if a.map[0] == map_name: for e in a._entry_: + host = h.name[0] + if auto_domain: + host += auto_domain path = '/'.join([a.root[0], e.path[0]]) - auto[e.key[0]] = "%s:%s" % (h.name[0],path) + auto[e.key[0]] = "%s:%s" % (host, path) ak = auto.keys() ak.sort() result = ""