diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index 4e405a035..d91a1caab 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -1,5 +1,6 @@ from django import forms from django.contrib.contenttypes.models import ContentType +from django.contrib.postgres.forms import IntegerRangeField, SimpleArrayField from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ @@ -632,10 +633,15 @@ class VLANGroupForm(NetBoxModelForm): } ) slug = SlugField() + # vlan_id_ranges = SimpleArrayField( + # IntegerRangeField(), + # delimiter="|" + # ) + vlan_id_ranges = IntegerRangeField() fieldsets = ( FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')), - FieldSet('min_vid', 'max_vid', name=_('Child VLANs')), + FieldSet('min_vid', 'max_vid', 'vlan_id_ranges', name=_('Child VLANs')), FieldSet( 'scope_type', 'region', 'sitegroup', 'site', 'location', 'rack', 'clustergroup', 'cluster', name=_('Scope') @@ -646,7 +652,7 @@ class VLANGroupForm(NetBoxModelForm): model = VLANGroup fields = [ 'name', 'slug', 'description', 'scope_type', 'region', 'sitegroup', 'site', 'location', 'rack', - 'clustergroup', 'cluster', 'min_vid', 'max_vid', 'tags', + 'clustergroup', 'cluster', 'min_vid', 'max_vid', 'vlan_id_ranges', 'tags', ] def __init__(self, *args, **kwargs): diff --git a/netbox/ipam/graphql/types.py b/netbox/ipam/graphql/types.py index 36e09eaac..061545d42 100644 --- a/netbox/ipam/graphql/types.py +++ b/netbox/ipam/graphql/types.py @@ -251,6 +251,7 @@ class VLANType(NetBoxObjectType): class VLANGroupType(OrganizationalObjectType): vlans: List[VLANType] + vlan_id_ranges: List[int] @strawberry_django.field def scope(self) -> Annotated[Union[ diff --git a/netbox/ipam/models/vlans.py b/netbox/ipam/models/vlans.py index 7434bd0b4..83f8e0937 100644 --- a/netbox/ipam/models/vlans.py +++ b/netbox/ipam/models/vlans.py @@ -1,4 +1,5 @@ from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation +from django.contrib.postgres.fields import ArrayField, BigIntegerRangeField from django.core.exceptions import ValidationError from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models @@ -63,6 +64,13 @@ class VLANGroup(OrganizationalModel): ), help_text=_('Highest permissible ID of a child VLAN') ) + vlan_id_ranges = ArrayField( + BigIntegerRangeField(), + verbose_name=_('min/max VLAN IDs'), + help_text=_('Ranges of Minimum, maximum VLAN IDs'), + blank=True, + null=True + ) objects = VLANGroupQuerySet.as_manager()