Commit 0eefb091 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Version 2011-04-04 16:27

M  src/hostinfo.py
M  src/hostinfo/dhcpd.py
parent dc973c1c
......@@ -192,6 +192,9 @@ if __name__ == '__main__':
optParser.add_option("--named",
action="store", metavar="DIR",
help="Generate DIR/named.conf and DIR/named/*")
optParser.add_option("--next_server",
action="store", metavar="HOST",
help="Use HOST as DHCP next-server")
optParser.add_option("--pretty",
action="store_true", default=False,
help="pretty-print XML tree")
......@@ -232,7 +235,9 @@ if __name__ == '__main__':
kickstart = os.path.abspath(options.kickstart)
else:
kickstart = None
file[name] = hostinfo.dhcpd.conf(tree, host, kickstart)
pass
file[name] = hostinfo.dhcpd.conf(tree, host, kickstart,
next_server=options.next_server)
if options.ifconfig:
for (f, c) in hostinfo.ifconfig.generate(tree, host):
......
......@@ -46,7 +46,8 @@ class "AppleNBI-ppc" {
""" % (dhcphost, dhcphost)
def conf(tree, dhcphost, kickstart):
def conf(tree, dhcphost, kickstart, next_server=None):
print next_server
#
# A. Get interfaces to serve
#
......@@ -83,13 +84,16 @@ def conf(tree, dhcphost, kickstart):
vlan.append(ip.address[0])
result += emit_network(tree, dhcphost, address, kickstart,
i.ethernet[0])
i.ethernet[0], next_server=next_server)
for v in vlan:
result += emit_network(tree, dhcphost, [ v ], kickstart)
result += emit_network(tree, dhcphost, [ v ], kickstart,
None, next_server=next_server)
return result
def emit_network(tree, dhcphost, addr, kickstart, ethernet=None):
def emit_network(tree, dhcphost, addr, kickstart, ethernet=None,
next_server=None):
print next_server
result = ""
network = {}
for n in tree._subnet_:
......@@ -104,16 +108,22 @@ def emit_network(tree, dhcphost, addr, kickstart, ethernet=None):
# Multiple networks served on this interface
result += 'shared-network "MAC(%s)" {\n\n' % ethernet
for n in network.values():
for l in emit_subnet(tree, n, dhcphost, kickstart).split("\n"):
for l in emit_subnet(tree, n, dhcphost, kickstart,
next_server=next_server).split("\n"):
result += " %s\n" % l
result += "}\n"
else:
result += emit_subnet(tree, network.values()[0], dhcphost, kickstart)
result += emit_subnet(tree, network.values()[0], dhcphost, kickstart,
next_server=next_server)
return result
def emit_subnet(tree, n, dhcphost, kickstart):
def emit_subnet(tree, n, dhcphost, kickstart, next_server=None):
result = ""
print next_server,dhcphost
if next_server == None:
next_server = dhcphost
pass
netmask = aton(n.netmask[0])
subnet = aton(n.network[0]) & netmask
static = {}
......@@ -188,7 +198,7 @@ def emit_subnet(tree, n, dhcphost, kickstart):
raise Exception("--kickstart needed for %s" % i.name[0:])
kf = i._kickstart_[0].file[0]
result += " server-name \"%s\";\n" % dhcphost
result += " next-server %s;\n" % dhcphost
result += " next-server %s;\n" % next_server
result += " if substring(option vendor-class-identifier, "
result += "0, 20) = \n"
result += " \"PXEClient:Arch:00000\" {\n"
......
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