wip
This commit is contained in:
parent
3b89fb7886
commit
6d8f227e83
4 changed files with 29 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
from ipaddress import ip_interface
|
from ipaddress import ip_interface, ip_network
|
||||||
|
|
||||||
hashable = repo.libs.hashable.hashable
|
hashable = repo.libs.hashable.hashable
|
||||||
|
|
||||||
|
@ -36,16 +36,28 @@ defaults = {
|
||||||
|
|
||||||
|
|
||||||
@metadata_reactor.provides(
|
@metadata_reactor.provides(
|
||||||
'kea',
|
'kea/Dhcp4/interfaces-config/interfaces',
|
||||||
|
'kea/Dhcp4/subnet4',
|
||||||
)
|
)
|
||||||
def subnets(metadata):
|
def subnets(metadata):
|
||||||
subnet4 = set()
|
subnet4 = set()
|
||||||
interfaces = set()
|
interfaces = set()
|
||||||
|
reservations = set(
|
||||||
|
hashable({
|
||||||
|
'hw-address': network_conf['mac'],
|
||||||
|
'ip-address': str(ip_interface(network_conf['ipv4']).ip),
|
||||||
|
})
|
||||||
|
for other_node in repo.nodes
|
||||||
|
for network_conf in other_node.metadata.get('network', {}).values()
|
||||||
|
if 'mac' in network_conf
|
||||||
|
)
|
||||||
|
|
||||||
for network_name, network_conf in metadata.get('network').items():
|
for network_name, network_conf in metadata.get('network').items():
|
||||||
dhcp_server_config = network_conf.get('dhcp_server_config', None)
|
dhcp_server_config = network_conf.get('dhcp_server_config', None)
|
||||||
|
|
||||||
if dhcp_server_config:
|
if dhcp_server_config:
|
||||||
|
_network = ip_network(dhcp_server_config['subnet'])
|
||||||
|
|
||||||
subnet4.add(hashable({
|
subnet4.add(hashable({
|
||||||
'subnet': dhcp_server_config['subnet'],
|
'subnet': dhcp_server_config['subnet'],
|
||||||
'pools': [
|
'pools': [
|
||||||
|
@ -63,7 +75,13 @@ def subnets(metadata):
|
||||||
'data': '10.0.10.2',
|
'data': '10.0.10.2',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'reservations': set(
|
||||||
|
reservation
|
||||||
|
for reservation in reservations
|
||||||
|
if ip_interface(reservation['ip-address']).ip in _network
|
||||||
|
),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
interfaces.add(network_conf.get('interface', network_name))
|
interfaces.add(network_conf.get('interface', network_name))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
'internal': {
|
'internal': {
|
||||||
'interface': 'eth0',
|
'interface': 'eth0',
|
||||||
'ipv4': '10.0.0.16/24',
|
'ipv4': '10.0.0.16/24',
|
||||||
|
'mac': 'd8:3a:dd:16:fc:9d',
|
||||||
'gateway4': '10.0.0.1',
|
'gateway4': '10.0.0.1',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
'network': {
|
'network': {
|
||||||
'internal': {
|
'internal': {
|
||||||
'ipv4': '10.0.2.8/24',
|
'ipv4': '10.0.2.8/24',
|
||||||
|
'mac': 'b8:27:eb:15:30:86',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'dns': {
|
'dns': {
|
||||||
|
|
|
@ -5,7 +5,13 @@
|
||||||
'home',
|
'home',
|
||||||
],
|
],
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'id': '',
|
'id': '87879bc1-130f-4fca-a8d2-e1d93a794df4',
|
||||||
|
'network': {
|
||||||
|
'internal': {
|
||||||
|
'ipv4': '10.0.2.100/24',
|
||||||
|
'mac': '00:17:88:67:e7:f2',
|
||||||
|
},
|
||||||
|
},
|
||||||
'dns': {
|
'dns': {
|
||||||
'hue.ckn.li': {
|
'hue.ckn.li': {
|
||||||
'A': {'10.0.2.100'},
|
'A': {'10.0.2.100'},
|
||||||
|
|
Loading…
Reference in a new issue