42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
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
|