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