1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

#6934: Correct prefix utilization and available IP reporting to account for child IP ranges

This commit is contained in:
jeremystretch
2021-08-13 10:43:25 -04:00
parent 5365c866ff
commit 7727ec91f4
3 changed files with 10 additions and 6 deletions

View File

@@ -435,7 +435,10 @@ class Prefix(PrimaryModel):
prefix = netaddr.IPSet(self.prefix)
child_ips = netaddr.IPSet([ip.address.ip for ip in self.get_child_ips()])
available_ips = prefix - child_ips
child_ranges = netaddr.IPSet()
for iprange in self.get_child_ranges():
child_ranges.add(iprange.range)
available_ips = prefix - child_ips - child_ranges
# IPv6, pool, or IPv4 /31-/32 sets are fully usable
if self.family == 6 or self.is_pool or (self.family == 4 and self.prefix.prefixlen >= 31):