mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 03:16:25 -06:00
18296 add tenant to vlan groups
This commit is contained in:
parent
883113fa7d
commit
c704e39b9a
@ -37,6 +37,7 @@ class VLANGroupSerializer(NetBoxModelSerializer):
|
|||||||
scope = serializers.SerializerMethodField(read_only=True)
|
scope = serializers.SerializerMethodField(read_only=True)
|
||||||
vid_ranges = IntegerRangeSerializer(many=True, required=False)
|
vid_ranges = IntegerRangeSerializer(many=True, required=False)
|
||||||
utilization = serializers.CharField(read_only=True)
|
utilization = serializers.CharField(read_only=True)
|
||||||
|
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
||||||
|
|
||||||
# Related object counts
|
# Related object counts
|
||||||
vlan_count = RelatedObjectCountField('vlans')
|
vlan_count = RelatedObjectCountField('vlans')
|
||||||
@ -45,7 +46,7 @@ class VLANGroupSerializer(NetBoxModelSerializer):
|
|||||||
model = VLANGroup
|
model = VLANGroup
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'url', 'display_url', 'display', 'name', 'slug', 'scope_type', 'scope_id', 'scope', 'vid_ranges',
|
'id', 'url', 'display_url', 'display', 'name', 'slug', 'scope_type', 'scope_id', 'scope', 'vid_ranges',
|
||||||
'description', 'tags', 'custom_fields', 'created', 'last_updated', 'vlan_count', 'utilization'
|
'tenant', 'description', 'tags', 'custom_fields', 'created', 'last_updated', 'vlan_count', 'utilization'
|
||||||
]
|
]
|
||||||
brief_fields = ('id', 'url', 'display', 'name', 'slug', 'description', 'vlan_count')
|
brief_fields = ('id', 'url', 'display', 'name', 'slug', 'description', 'vlan_count')
|
||||||
validators = []
|
validators = []
|
||||||
|
@ -857,7 +857,7 @@ class FHRPGroupAssignmentFilterSet(ChangeLoggedModelFilterSet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class VLANGroupFilterSet(OrganizationalModelFilterSet):
|
class VLANGroupFilterSet(OrganizationalModelFilterSet, TenancyFilterSet):
|
||||||
scope_type = ContentTypeFilter()
|
scope_type = ContentTypeFilter()
|
||||||
region = django_filters.NumberFilter(
|
region = django_filters.NumberFilter(
|
||||||
method='filter_scope'
|
method='filter_scope'
|
||||||
|
@ -430,11 +430,17 @@ class VLANGroupBulkEditForm(NetBoxModelBulkEditForm):
|
|||||||
label=_('VLAN ID ranges'),
|
label=_('VLAN ID ranges'),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
|
tenant = DynamicModelChoiceField(
|
||||||
|
label=_('Tenant'),
|
||||||
|
queryset=Tenant.objects.all(),
|
||||||
|
required=False
|
||||||
|
)
|
||||||
|
|
||||||
model = VLANGroup
|
model = VLANGroup
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('site', 'vid_ranges', 'description'),
|
FieldSet('site', 'vid_ranges', 'description'),
|
||||||
FieldSet('scope_type', 'scope', name=_('Scope')),
|
FieldSet('scope_type', 'scope', name=_('Scope')),
|
||||||
|
FieldSet('tenant', name=_('Tenancy')),
|
||||||
)
|
)
|
||||||
nullable_fields = ('description', 'scope')
|
nullable_fields = ('description', 'scope')
|
||||||
|
|
||||||
|
@ -438,10 +438,17 @@ class VLANGroupImportForm(NetBoxModelImportForm):
|
|||||||
vid_ranges = NumericRangeArrayField(
|
vid_ranges = NumericRangeArrayField(
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
|
tenant = CSVModelChoiceField(
|
||||||
|
label=_('Tenant'),
|
||||||
|
queryset=Tenant.objects.all(),
|
||||||
|
required=False,
|
||||||
|
to_field_name='name',
|
||||||
|
help_text=_('Assigned tenant')
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VLANGroup
|
model = VLANGroup
|
||||||
fields = ('name', 'slug', 'scope_type', 'scope_id', 'vid_ranges', 'description', 'tags')
|
fields = ('name', 'slug', 'scope_type', 'scope_id', 'vid_ranges', 'tenant', 'description', 'tags')
|
||||||
labels = {
|
labels = {
|
||||||
'scope_id': 'Scope ID',
|
'scope_id': 'Scope ID',
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ class FHRPGroupAssignmentForm(forms.ModelForm):
|
|||||||
return group
|
return group
|
||||||
|
|
||||||
|
|
||||||
class VLANGroupForm(NetBoxModelForm):
|
class VLANGroupForm(TenancyForm, NetBoxModelForm):
|
||||||
slug = SlugField()
|
slug = SlugField()
|
||||||
vid_ranges = NumericRangeArrayField(
|
vid_ranges = NumericRangeArrayField(
|
||||||
label=_('VLAN IDs')
|
label=_('VLAN IDs')
|
||||||
@ -621,12 +621,13 @@ class VLANGroupForm(NetBoxModelForm):
|
|||||||
FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')),
|
FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')),
|
||||||
FieldSet('vid_ranges', name=_('Child VLANs')),
|
FieldSet('vid_ranges', name=_('Child VLANs')),
|
||||||
FieldSet('scope_type', 'scope', name=_('Scope')),
|
FieldSet('scope_type', 'scope', name=_('Scope')),
|
||||||
|
FieldSet('tenant_group', 'tenant', name=_('Tenancy')),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VLANGroup
|
model = VLANGroup
|
||||||
fields = [
|
fields = [
|
||||||
'name', 'slug', 'description', 'vid_ranges', 'scope_type', 'tags',
|
'name', 'slug', 'description', 'vid_ranges', 'scope_type', 'tenant_group', 'tenant', 'tags',
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -266,6 +266,7 @@ class VLANGroupType(OrganizationalObjectType):
|
|||||||
|
|
||||||
vlans: List[VLANType]
|
vlans: List[VLANType]
|
||||||
vid_ranges: List[str]
|
vid_ranges: List[str]
|
||||||
|
tenant: Annotated["TenantType", strawberry.lazy('tenancy.graphql.types')] | None
|
||||||
|
|
||||||
@strawberry_django.field
|
@strawberry_django.field
|
||||||
def scope(self) -> Annotated[Union[
|
def scope(self) -> Annotated[Union[
|
||||||
|
@ -65,9 +65,11 @@ class VLANGroupTable(NetBoxTable):
|
|||||||
model = VLANGroup
|
model = VLANGroup
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'scope_type', 'scope', 'vid_ranges_list', 'vlan_count', 'slug', 'description',
|
'pk', 'id', 'name', 'scope_type', 'scope', 'vid_ranges_list', 'vlan_count', 'slug', 'description',
|
||||||
'tags', 'created', 'last_updated', 'actions', 'utilization',
|
'tenant', 'tenant_group', 'tags', 'created', 'last_updated', 'actions', 'utilization',
|
||||||
|
)
|
||||||
|
default_columns = (
|
||||||
|
'pk', 'name', 'scope_type', 'scope', 'vlan_count', 'utilization', 'tenant', 'tenant_group', 'description'
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'name', 'scope_type', 'scope', 'vlan_count', 'utilization', 'description')
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user