Add mark_utilized to IPRange

This commit is contained in:
jeremystretch
2023-02-28 10:09:09 -05:00
committed by Jeremy Stretch
parent 8a08d3621b
commit 536b46158a
12 changed files with 61 additions and 10 deletions

View File

@@ -511,6 +511,10 @@ class IPRange(PrimaryModel):
null=True,
help_text=_('The primary function of this range')
)
mark_utilized = models.BooleanField(
default=False,
help_text=_("Treat as 100% utilized")
)
clone_fields = (
'vrf', 'tenant', 'status', 'role', 'description',
@@ -652,6 +656,9 @@ class IPRange(PrimaryModel):
"""
Determine the utilization of the range and return it as a percentage.
"""
if self.mark_utilized:
return 100
# Compile an IPSet to avoid counting duplicate IPs
child_count = netaddr.IPSet([
ip.address.ip for ip in self.get_child_ips()