mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge pull request #7366 from shuichiro-makigaki/optimize-prefix-util
Fix #7365: Optimize calculation of prefix utilization
This commit is contained in:
@ -487,11 +487,9 @@ class Prefix(PrimaryModel):
|
||||
utilization = int(float(child_prefixes.size) / self.prefix.size * 100)
|
||||
else:
|
||||
# Compile an IPSet to avoid counting duplicate IPs
|
||||
child_ips = netaddr.IPSet()
|
||||
for iprange in self.get_child_ranges():
|
||||
child_ips.add(iprange.range)
|
||||
for ip in self.get_child_ips():
|
||||
child_ips.add(ip.address.ip)
|
||||
child_ips = netaddr.IPSet(
|
||||
[_.range for _ in self.get_child_ranges()] + [_.address.ip for _ in self.get_child_ips()]
|
||||
)
|
||||
|
||||
prefix_size = self.prefix.size
|
||||
if self.prefix.version == 4 and self.prefix.prefixlen < 31 and not self.is_pool:
|
||||
|
Reference in New Issue
Block a user