Skip to content

Commit 1de0fc5

Browse files
author
Henri Strand
committed
Support for shared networks mweinelt#17
1 parent 94ae583 commit 1de0fc5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

kea_exporter/kea.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,22 @@ def reload(self):
5858

5959
if 'Dhcp4' in self.config:
6060
self.dhcp_version = DHCPVersion.DHCP4
61-
subnets = self.config['Dhcp4']['subnet4']
61+
subnet_type = 'subnet4'
62+
subnets = self.config['Dhcp4']['subnet4'] if 'subnet4' in self.config['Dhcp4'] else None
63+
shared_networks = self.config['Dhcp4']['shared-networks'] if 'shared-networks' in self.config['Dhcp4'] else None
6264
elif 'Dhcp6' in self.config:
6365
self.dhcp_version = DHCPVersion.DHCP6
64-
subnets = self.config['Dhcp6']['subnet6']
66+
subnet_type = 'subnet6'
67+
subnets = self.config['Dhcp6']['subnet6'] if 'subnet6' in self.config['Dhcp6'] else None
68+
shared_networks = self.config['Dhcp6']['shared-networks'] if 'shared-networks' in self.config['Dhcp6'] else None
6569
else:
6670
click.echo(f'Socket {self.sock_path} has no supported configuration', file=sys.stderr)
6771
sys.exit(1)
6872

6973
# create subnet map
70-
self.subnets = {subnet['id']: subnet for subnet in subnets}
74+
self.subnets = {}
75+
self.subnets |= {subnet['id']: subnet for subnet in subnets} if subnets != None else {}
76+
self.subnets |= {subnet['id']: subnet for shared_network in shared_networks for subnet in shared_network[subnet_type]} if shared_networks != None else {}
7177

7278

7379
class KeaExporter:

0 commit comments

Comments
 (0)