mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-21 12:52:21 -06:00
Add mark_utilized to IPRange
This commit is contained in:
committed by
Jeremy Stretch
parent
8a08d3621b
commit
536b46158a
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user