2020-11-13 21:11:56 +00:00
|
|
|
defaults = {
|
|
|
|
'apt': {
|
|
|
|
'packages': {
|
2020-11-13 22:30:21 +00:00
|
|
|
'isc-dhcp-server': {},
|
2020-11-13 21:11:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor
|
|
|
|
def get_static_allocations(metadata):
|
|
|
|
allocations = {}
|
|
|
|
for rnode in repo.nodes_in_group('home'):
|
|
|
|
for identifier, interface in rnode.metadata.get('interfaces', {}).items():
|
|
|
|
if interface.get('dhcp', False):
|
|
|
|
allocations[rnode.name] = {
|
|
|
|
'ipv4': sorted(interface['ips'])[0],
|
|
|
|
'mac': interface['mac'],
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
'dhcpd': {
|
|
|
|
'fixed_allocations': allocations,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-13 22:30:21 +00:00
|
|
|
@metadata_reactor
|
|
|
|
def get_listen_interfaces(metadata):
|
|
|
|
listen_interfaces = []
|
|
|
|
for identfier, subnet in node.metadata.get('dhcpd/subnets', {}).items():
|
|
|
|
listen_interfaces.append(subnet.get('interface'))
|
|
|
|
|
|
|
|
return {
|
|
|
|
'dhcpd': {
|
|
|
|
'listen_interfaces': ' '.join(sorted(listen_interfaces)),
|
|
|
|
}
|
|
|
|
}
|