mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 00:58:16 -06:00
9627 add stuff for utilization calc
This commit is contained in:
parent
da8cf67d5e
commit
2f38ecc268
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import django.contrib.postgres.fields
|
import django.contrib.postgres.fields
|
||||||
import django.contrib.postgres.fields.ranges
|
import django.contrib.postgres.fields.ranges
|
||||||
from django.db import migrations
|
from django.db import migrations, models
|
||||||
from django.db.backends.postgresql.psycopg_any import NumericRange
|
from django.db.backends.postgresql.psycopg_any import NumericRange
|
||||||
|
|
||||||
|
|
||||||
@ -26,6 +26,11 @@ class Migration(migrations.Migration):
|
|||||||
name='vlan_id_ranges',
|
name='vlan_id_ranges',
|
||||||
field=django.contrib.postgres.fields.ArrayField(base_field=django.contrib.postgres.fields.ranges.BigIntegerRangeField(), blank=True, null=True, size=None),
|
field=django.contrib.postgres.fields.ArrayField(base_field=django.contrib.postgres.fields.ranges.BigIntegerRangeField(), blank=True, null=True, size=None),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='vlangroup',
|
||||||
|
name='_total_vlan_ids',
|
||||||
|
field=models.PositiveBigIntegerField(default=0),
|
||||||
|
),
|
||||||
migrations.RunPython(
|
migrations.RunPython(
|
||||||
code=move_min_max,
|
code=move_min_max,
|
||||||
reverse_code=migrations.RunPython.noop
|
reverse_code=migrations.RunPython.noop
|
||||||
|
@ -53,6 +53,9 @@ class VLANGroup(OrganizationalModel):
|
|||||||
blank=True,
|
blank=True,
|
||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
|
_total_vlan_ids = models.PositiveBigIntegerField(
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
|
||||||
objects = VLANGroupQuerySet.as_manager()
|
objects = VLANGroupQuerySet.as_manager()
|
||||||
|
|
||||||
@ -92,6 +95,13 @@ class VLANGroup(OrganizationalModel):
|
|||||||
'max_vid': _("Maximum child VID must be greater than or equal to minimum child VID")
|
'max_vid': _("Maximum child VID must be greater than or equal to minimum child VID")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
self._total_vlan_ids = 0
|
||||||
|
for range in vland_id_ranges:
|
||||||
|
self._total_vlan_ids += range.upper - range.lower + 1
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def get_available_vids(self):
|
def get_available_vids(self):
|
||||||
"""
|
"""
|
||||||
Return all available VLANs within this group.
|
Return all available VLANs within this group.
|
||||||
|
Loading…
Reference in New Issue
Block a user