Closed sorah closed 5 years ago
Hey, sorry for not getting back to you earlier. The documentation links are unfortunately dead by now.
Here is what it says:
The subnet identifier is a unique number associated with a particular subnet. In principle, it is used to associate clients' leases with their respective subnets. When a subnet identifier is not specified for a subnet being configured, it will be automatically assigned by the configuration mechanism. The identifiers are assigned from 1 and are monotonically increased for each subsequent subnet: 1, 2, 3 ....
I'll think this through and will probably give your change a testdrive.
Another point would be the consideration of subnets in shared_networks (don't know with which version they got introduced). I needed to adapt some things, so that exporter does not crash. Probably I'm opening a pull request to implement that.
My change to not crash when subnet is in statistics, but not in config. And subnet id is not in numerical order:
if key.startswith('subnet['):
match = self.subnet_pattern.match(key)
if match:
subnet_idx = int(match.group('subnet_idx')) - 1
key = match.group('metric')
indexes={}
index = 0
for element in self.config['Dhcp4']['subnet4']:
indexes[element['id']] = index
index+=1
if not subnet_idx in indexes:
continue
if module is Module.DHCP4:
subnet = self.config['Dhcp4']['subnet4'][indexes[subnet_idx]]
The subnet ids are part of the configuration when requested over the socket, so we don't need the additional logic.
I noticed that when change subnet ids the statistic-get-all command still returns statistics for subnets that are not part of the configuration anymore, and I don't think we should render metrics in that case.
Either way, I'll address subnet ids shortly, shared networks are another thing to tackle, although I have no such setup, so it may take another while.
https://kea.isc.org/docs/kea-guide.html#ipv4-subnet-id https://kea.isc.org/docs/kea-guide.html#ipv6-subnet-id
Kea assigns monotonically increased ID to subnets when ID is not given on a configuration file.