mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-15 11:42:52 -06:00
Merge pull request #10114 from netbox-community/10109-available-prefixes
Fixes #10109: Fix available prefixes calculation for container prefixes in the global table
This commit is contained in:
commit
bf92e3a9dd
@ -17,6 +17,7 @@
|
||||
* [#10059](https://github.com/netbox-community/netbox/issues/10059) - Add identifier column to L2VPN table
|
||||
* [#10089](https://github.com/netbox-community/netbox/issues/10089) - `linkify` template filter should escape object representation
|
||||
* [#10108](https://github.com/netbox-community/netbox/issues/10108) - Linkify inside NAT IPs for primary device IPs in UI
|
||||
* [#10109](https://github.com/netbox-community/netbox/issues/10109) - Fix available prefixes calculation for container prefixes in the global table
|
||||
* [#10111](https://github.com/netbox-community/netbox/issues/10111) - Wrap search QS to catch ValueError on identifier field
|
||||
|
||||
---
|
||||
|
@ -35,13 +35,16 @@ class GetAvailablePrefixesMixin:
|
||||
|
||||
def get_available_prefixes(self):
|
||||
"""
|
||||
Return all available Prefixes within this aggregate as an IPSet.
|
||||
Return all available prefixes within this Aggregate or Prefix as an IPSet.
|
||||
"""
|
||||
prefix = netaddr.IPSet(self.prefix)
|
||||
child_prefixes = netaddr.IPSet([child.prefix for child in self.get_child_prefixes()])
|
||||
available_prefixes = prefix - child_prefixes
|
||||
params = {
|
||||
'prefix__net_contained': str(self.prefix)
|
||||
}
|
||||
if hasattr(self, 'vrf'):
|
||||
params['vrf'] = self.vrf
|
||||
|
||||
return available_prefixes
|
||||
child_prefixes = Prefix.objects.filter(**params).values_list('prefix', flat=True)
|
||||
return netaddr.IPSet(self.prefix) - netaddr.IPSet(child_prefixes)
|
||||
|
||||
def get_first_available_prefix(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user