Commit 1eaf1523 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Version 2011-05-31 17:06

M  src/hostinfo.py
A  src/hostinfo/automount.py
parent b72a45cc
#!/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:
......
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment