Commit f03a4c60 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Version 2013-10-24 11:23

M  src/hostinfo/dhcpd.py
M  src/hostinfo/yp.py
parent b6dd7535
......@@ -80,8 +80,9 @@ option PXE.mtftp-tmout code 4 = unsigned integer 8;
option PXE.mtftp-delay code 5 = unsigned integer 8;
option arch code 93 = unsigned integer 16; # RFC4578
class "pxeclient_allow" {
class "pxeclient" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
next-server %(next_server)s;
if option arch = 00:06 {
filename "bootia32.efi";
} else if option arch = 00:07 {
......@@ -93,31 +94,12 @@ class "pxeclient_allow" {
"""
PXE_DENY="""
class "pxeclient_deny" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
ignore booting;
}
"""
CLASS_PXECLIENT = """
class "pxeclient" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
next-server %(next_server)s;
if option arch = 00:06 {
filename "bootia32.efi";
} else if option arch = 00:07 {
filename "bootx64.efi";
} else {
filename "pxelinux.0";
}
}
}
class "noboot" {
match if substring (option vendor-class-identifier, 0, 9) != "PXEClient";
ignore booting;
}
"""
def MacOS_NETBOOT(dhcphost):
if not os.path.exists('/local/macos'):
return ''
......@@ -175,7 +157,10 @@ def generate(tree, options):
|use-host-decl-names on;
""")
if get_pxeboot(dhcp) == 'only':
result += PXE_ALLOW
if not options.next_server:
raise util.HostinfoException('next_server not defined',
where=dhcp)
result += PXE_ALLOW % dict(next_server=options.next_server)
pass
else:
result += PXE_DENY
......@@ -193,7 +178,8 @@ def generate(tree, options):
def emit_interface(tree, options, interface):
result = util.StringArray()
subnet = dict(map(lambda d: (get_subnet(tree, d._parent), d),
subnet = dict(map(lambda d: (get_subnet(tree, d._parent),
map(None, d._parent._dhcpserver_)),
interface._ip_._dhcpserver_))
result += 'shared-network "MAC(%s)" {' % interface.ethernet[0]
for sn,dhcp in map(lambda n: (n, subnet[n]), sorted(subnet)):
......@@ -217,9 +203,10 @@ def emit_network(tree, options, subnet, dhcp):
netmask=net.netmask,
broadcast=net.broadcast,
host=options.host))
if dhcp.first[0] and dhcp.last[0]:
first = util.address(dhcp.first[0])
last = util.address(dhcp.last[0])
for d in dhcp:
if d.first[0] and d.last[0]:
first = util.address(d.first[0])
last = util.address(d.last[0])
assert first in net, '%s not part of %s' % (first, net)
assert last in net, '%s not part of %s' % (last, net)
if pxeboot == 'no':
......@@ -233,6 +220,7 @@ def emit_network(tree, options, subnet, dhcp):
| }""" % dict(first=first, last=last))
pass
pass
pass
result += emit_subnet_info(subnet).indent()
result += '}'
return result
......@@ -346,7 +334,10 @@ def get_subnet(tree, ip):
def get_pxeboot(dhcp):
try:
p = set(map(lambda d: d.pxeboot[0] or 'no', dhcp))
assert len(p) == 1, "Mixed pxeboot not allowed (%s)" % ','.join(p)
if len(p) != 1:
raise util.HostinfoException("Mixed pxeboot not allowed (%s)" %
','.join(p),
where=dhcp)
result = p.pop()
pass
except TypeError:
......
......@@ -103,9 +103,16 @@ def netgroup(tree):
pass
pass
for g in tree._host_._interface_._netgroup_:
for ip in filter(lambda ip: (not ip.alias[0] and not ip.vlan[0] and
not ip.never[0]),
g._parent._ip_):
def exclude(ip):
if ip.alias[0] or ip.vlan[0] or ip.never[0]:
return False
if ip.exclude_netgroups[0]:
if g.name[0] in ip.exclude_netgroups[0].split(','):
return False
pass
return True
for ip in filter(exclude, g._parent._ip_):
if not g.name[0:] in netgroup:
netgroup[g.name[0:]] = [ ]
pass
......
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