diff --git a/bundles/kea-dhcpd/metadata.py b/bundles/kea-dhcpd/metadata.py index 7407759..2e27323 100644 --- a/bundles/kea-dhcpd/metadata.py +++ b/bundles/kea-dhcpd/metadata.py @@ -1,4 +1,4 @@ -from ipaddress import ip_interface +from ipaddress import ip_interface, ip_network hashable = repo.libs.hashable.hashable @@ -36,16 +36,28 @@ defaults = { @metadata_reactor.provides( - 'kea', + 'kea/Dhcp4/interfaces-config/interfaces', + 'kea/Dhcp4/subnet4', ) def subnets(metadata): subnet4 = 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(): dhcp_server_config = network_conf.get('dhcp_server_config', None) if dhcp_server_config: + _network = ip_network(dhcp_server_config['subnet']) + subnet4.add(hashable({ 'subnet': dhcp_server_config['subnet'], 'pools': [ @@ -63,7 +75,13 @@ def subnets(metadata): '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)) return { diff --git a/nodes/home.homeassistant.py b/nodes/home.homeassistant.py index 01516f1..ca03dc2 100644 --- a/nodes/home.homeassistant.py +++ b/nodes/home.homeassistant.py @@ -29,6 +29,7 @@ 'internal': { 'interface': 'eth0', 'ipv4': '10.0.0.16/24', + 'mac': 'd8:3a:dd:16:fc:9d', 'gateway4': '10.0.0.1', }, }, diff --git a/nodes/home.homematic.py b/nodes/home.homematic.py index 5b9357e..b716d3f 100644 --- a/nodes/home.homematic.py +++ b/nodes/home.homematic.py @@ -14,6 +14,7 @@ 'network': { 'internal': { 'ipv4': '10.0.2.8/24', + 'mac': 'b8:27:eb:15:30:86', }, }, 'dns': { diff --git a/nodes/home.hue.py b/nodes/home.hue.py index c1df787..0470bf3 100644 --- a/nodes/home.hue.py +++ b/nodes/home.hue.py @@ -5,7 +5,13 @@ 'home', ], 'metadata': { - 'id': '', + 'id': '87879bc1-130f-4fca-a8d2-e1d93a794df4', + 'network': { + 'internal': { + 'ipv4': '10.0.2.100/24', + 'mac': '00:17:88:67:e7:f2', + }, + }, 'dns': { 'hue.ckn.li': { 'A': {'10.0.2.100'},