diff --git a/src/hostinfo.py b/src/hostinfo.py index e25bb9c5bff267289fd3e7b97ddeeb8aa41c313b..7968ff121d093456d4be5d84cd493b4ea20b7311 100755 --- a/src/hostinfo.py +++ b/src/hostinfo.py @@ -1,6 +1,7 @@ #!/usr/bin/python import copy +import hostinfo.automount import hostinfo.dhcpd import hostinfo.ifconfig import hostinfo.macosx_auto @@ -208,6 +209,12 @@ if __name__ == '__main__': optParser.add_option("--host", action="store", help="The host to generate information for") + optParser.add_option("--automount", + action="store", metavar="DIR", + help="generate automount maps in DIR") + optParser.add_option("--auto_domain", + action="store", metavar="DOMAIN", + help="DOMAIN name for automount maps") optParser.add_option("--dfs", action="store", metavar="DIR", help="generate DIR/*/(dfslink|autolink)") @@ -266,6 +273,10 @@ if __name__ == '__main__': for (f, c) in hostinfo.samba.msdfs(tree): symlink["%s/%s" % (options.dfs, f)] = c + if options.automount: + for (f, c) in hostinfo.automount.generate(tree,options.auto_domain): + file["%s/%s" % (options.automount, f)] = c + if options.dhcpd: name = "%s/dhcpd.conf" % options.dhcpd if options.kickstart: diff --git a/src/hostinfo/automount.py b/src/hostinfo/automount.py new file mode 100755 index 0000000000000000000000000000000000000000..283f22de8c537b9aae855d9c75ba153a4944393f --- /dev/null +++ b/src/hostinfo/automount.py @@ -0,0 +1,25 @@ +def generate(tree, auto_domain): + result = [] + 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 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" % (host, path) + ak = auto.keys() + ak.sort() + result = "" + for k in ak: + result += "%-15s %s\n" % (k, auto[k]) + return result + +