bundlewrap/bundles/kea-dhcp-server/items.py

43 lines
1.2 KiB
Python
Raw Normal View History

2023-09-09 16:40:10 +00:00
kea_config = {
'Dhcp4': {
**node.metadata.get('kea-dhcp-server/config'),
'interfaces-config': {
'interfaces': sorted(node.metadata.get('kea-dhcp-server/subnets', {}).keys()),
},
'subnet4': [],
},
'Server': {
'loggers': [{
'name': 'kea-dhcp4',
'output_options': [{
# -> journal
'output': 'stdout',
}],
'severity': 'WARN',
}],
},
}
for iface, config in sorted(node.metadata.get('kea-dhcp-server/subnets', {}).items()):
kea_config['Dhcp4']['subnet4'].append({
'subnet': config['subnet'],
'pools': [{
'pool': f'{config["lower"]} - {config["higher"]}',
}],
'option-data': [
{
'name': k,
'data': v,
} for k, v in sorted(config.get('options', {}).items())
],
'reservations': [
{
'ip-address': v['ip'],
'hw-address': v['mac'],
'hostname': k,
} for k, v in sorted(node.metadata.get(f'kea-dhcp-server/fixed_allocations/{iface}', {}).items())
]
})
# TODO deploy config