mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -06:00
#6934: Correct prefix utilization and available IP reporting to account for child IP ranges
This commit is contained in:
parent
5365c866ff
commit
7727ec91f4
@ -15,6 +15,7 @@
|
|||||||
* [#6846](https://github.com/netbox-community/netbox/issues/6846) - Form-driven REST API calls should use brief mode
|
* [#6846](https://github.com/netbox-community/netbox/issues/6846) - Form-driven REST API calls should use brief mode
|
||||||
* [#6871](https://github.com/netbox-community/netbox/issues/6871) - Support dynamic tag types in GraphQL API
|
* [#6871](https://github.com/netbox-community/netbox/issues/6871) - Support dynamic tag types in GraphQL API
|
||||||
* [#6894](https://github.com/netbox-community/netbox/issues/6894) - Fix available IP generation for prefix assigned to a VRF
|
* [#6894](https://github.com/netbox-community/netbox/issues/6894) - Fix available IP generation for prefix assigned to a VRF
|
||||||
|
* [#6934](https://github.com/netbox-community/netbox/issues/6934) - Correct prefix utilization and available IP reporting to account for child IP ranges
|
||||||
* [#6953](https://github.com/netbox-community/netbox/issues/6953) - Remove change log tab from non-applicable object views
|
* [#6953](https://github.com/netbox-community/netbox/issues/6953) - Remove change log tab from non-applicable object views
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -435,7 +435,10 @@ class Prefix(PrimaryModel):
|
|||||||
|
|
||||||
prefix = netaddr.IPSet(self.prefix)
|
prefix = netaddr.IPSet(self.prefix)
|
||||||
child_ips = netaddr.IPSet([ip.address.ip for ip in self.get_child_ips()])
|
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
|
# 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):
|
if self.family == 6 or self.is_pool or (self.family == 4 and self.prefix.prefixlen >= 31):
|
||||||
|
@ -142,17 +142,17 @@ class TestPrefix(TestCase):
|
|||||||
IPAddress(address=IPNetwork('10.0.0.3/26')),
|
IPAddress(address=IPNetwork('10.0.0.3/26')),
|
||||||
IPAddress(address=IPNetwork('10.0.0.5/26')),
|
IPAddress(address=IPNetwork('10.0.0.5/26')),
|
||||||
IPAddress(address=IPNetwork('10.0.0.7/26')),
|
IPAddress(address=IPNetwork('10.0.0.7/26')),
|
||||||
IPAddress(address=IPNetwork('10.0.0.9/26')),
|
|
||||||
IPAddress(address=IPNetwork('10.0.0.11/26')),
|
|
||||||
IPAddress(address=IPNetwork('10.0.0.13/26')),
|
|
||||||
))
|
))
|
||||||
|
IPRange.objects.create(
|
||||||
|
start_address=IPNetwork('10.0.0.9/26'),
|
||||||
|
end_address=IPNetwork('10.0.0.12/26')
|
||||||
|
)
|
||||||
missing_ips = IPSet([
|
missing_ips = IPSet([
|
||||||
'10.0.0.2/32',
|
'10.0.0.2/32',
|
||||||
'10.0.0.4/32',
|
'10.0.0.4/32',
|
||||||
'10.0.0.6/32',
|
'10.0.0.6/32',
|
||||||
'10.0.0.8/32',
|
'10.0.0.8/32',
|
||||||
'10.0.0.10/32',
|
'10.0.0.13/32',
|
||||||
'10.0.0.12/32',
|
|
||||||
'10.0.0.14/32',
|
'10.0.0.14/32',
|
||||||
])
|
])
|
||||||
available_ips = parent_prefix.get_available_ips()
|
available_ips = parent_prefix.get_available_ips()
|
||||||
|
Loading…
Reference in New Issue
Block a user