diff --git a/docs/models/circuits/providernetwork.md b/docs/models/circuits/providernetwork.md index f5a428e96..42c46e13c 100644 --- a/docs/models/circuits/providernetwork.md +++ b/docs/models/circuits/providernetwork.md @@ -2,4 +2,4 @@ This model can be used to represent the boundary of a provider network, the details of which are unknown or unimportant to the NetBox user. For example, it might represent a provider's regional MPLS network to which multiple circuits provide connectivity. -Each provider network must be assigned to a provider. A circuit may terminate to either a provider network or to a site. +Each provider network must be assigned to a provider, and may optionally be assigned an arbitrary service ID. A circuit may terminate to either a provider network or to a site. diff --git a/docs/release-notes/version-3.2.md b/docs/release-notes/version-3.2.md index b4a209007..2944b5ee9 100644 --- a/docs/release-notes/version-3.2.md +++ b/docs/release-notes/version-3.2.md @@ -41,6 +41,7 @@ FIELD_CHOICES = { ### Enhancements * [#7650](https://github.com/netbox-community/netbox/issues/7650) - Add support for local account password validation +* [#7681](https://github.com/netbox-community/netbox/issues/7681) - Add `service_id` field for provider networks * [#7759](https://github.com/netbox-community/netbox/issues/7759) - Improved the user preferences form * [#8168](https://github.com/netbox-community/netbox/issues/8168) - Add `min_vid` and `max_vid` fields to VLAN group @@ -58,6 +59,8 @@ FIELD_CHOICES = { * `/api/dcim/module-bays/` * `/api/dcim/module-bay-templates/` * `/api/dcim/module-types/` +* circuits.ProviderNetwork + * Added `service_id` field * dcim.ConsolePort * Added `module` field * dcim.ConsoleServerPort diff --git a/netbox/circuits/api/serializers.py b/netbox/circuits/api/serializers.py index 470a0b030..7a827d547 100644 --- a/netbox/circuits/api/serializers.py +++ b/netbox/circuits/api/serializers.py @@ -37,8 +37,8 @@ class ProviderNetworkSerializer(PrimaryModelSerializer): class Meta: model = ProviderNetwork fields = [ - 'id', 'url', 'display', 'provider', 'name', 'description', 'comments', 'tags', 'custom_fields', 'created', - 'last_updated', + 'id', 'url', 'display', 'provider', 'name', 'service_id', 'description', 'comments', 'tags', + 'custom_fields', 'created', 'last_updated', ] diff --git a/netbox/circuits/filtersets.py b/netbox/circuits/filtersets.py index fd582dd99..0a90116bd 100644 --- a/netbox/circuits/filtersets.py +++ b/netbox/circuits/filtersets.py @@ -98,13 +98,14 @@ class ProviderNetworkFilterSet(PrimaryModelFilterSet): class Meta: model = ProviderNetwork - fields = ['id', 'name'] + fields = ['id', 'name', 'service_id'] def search(self, queryset, name, value): if not value.strip(): return queryset return queryset.filter( Q(name__icontains=value) | + Q(service_id__icontains=value) | Q(description__icontains=value) | Q(comments__icontains=value) ).distinct() diff --git a/netbox/circuits/forms/bulk_edit.py b/netbox/circuits/forms/bulk_edit.py index 37edd3a62..af6bca91f 100644 --- a/netbox/circuits/forms/bulk_edit.py +++ b/netbox/circuits/forms/bulk_edit.py @@ -62,10 +62,14 @@ class ProviderNetworkBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditFor queryset=Provider.objects.all(), required=False ) - description = forms.CharField( + service_id = forms.CharField( max_length=100, required=False ) + description = forms.CharField( + max_length=200, + required=False + ) comments = CommentField( widget=SmallTextarea, label='Comments' @@ -73,7 +77,7 @@ class ProviderNetworkBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditFor class Meta: nullable_fields = [ - 'description', 'comments', + 'service_id', 'description', 'comments', ] diff --git a/netbox/circuits/forms/bulk_import.py b/netbox/circuits/forms/bulk_import.py index af5ec4425..fe1b927e5 100644 --- a/netbox/circuits/forms/bulk_import.py +++ b/netbox/circuits/forms/bulk_import.py @@ -32,7 +32,7 @@ class ProviderNetworkCSVForm(CustomFieldModelCSVForm): class Meta: model = ProviderNetwork fields = [ - 'provider', 'name', 'description', 'comments', + 'provider', 'name', 'service_id', 'description', 'comments', ] diff --git a/netbox/circuits/forms/filtersets.py b/netbox/circuits/forms/filtersets.py index 0822ff206..68b57e03c 100644 --- a/netbox/circuits/forms/filtersets.py +++ b/netbox/circuits/forms/filtersets.py @@ -64,6 +64,10 @@ class ProviderNetworkFilterForm(CustomFieldModelFilterForm): label=_('Provider'), fetch_trigger='open' ) + service_id = forms.CharField( + max_length=100, + required=False + ) tag = TagFilterField(model) diff --git a/netbox/circuits/forms/models.py b/netbox/circuits/forms/models.py index 2ea246fd0..f67114828 100644 --- a/netbox/circuits/forms/models.py +++ b/netbox/circuits/forms/models.py @@ -66,10 +66,10 @@ class ProviderNetworkForm(CustomFieldModelForm): class Meta: model = ProviderNetwork fields = [ - 'provider', 'name', 'description', 'comments', 'tags', + 'provider', 'name', 'service_id', 'description', 'comments', 'tags', ] fieldsets = ( - ('Provider Network', ('provider', 'name', 'description', 'tags')), + ('Provider Network', ('provider', 'name', 'service_id', 'description', 'tags')), ) diff --git a/netbox/circuits/migrations/0032_provider_service_id.py b/netbox/circuits/migrations/0032_provider_service_id.py new file mode 100644 index 000000000..91410bd96 --- /dev/null +++ b/netbox/circuits/migrations/0032_provider_service_id.py @@ -0,0 +1,16 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('circuits', '0004_rename_cable_peer'), + ] + + operations = [ + migrations.AddField( + model_name='providernetwork', + name='service_id', + field=models.CharField(blank=True, max_length=100), + ), + ] diff --git a/netbox/circuits/models/providers.py b/netbox/circuits/models/providers.py index b3a6902f9..153e241a7 100644 --- a/netbox/circuits/models/providers.py +++ b/netbox/circuits/models/providers.py @@ -5,7 +5,6 @@ from django.urls import reverse from dcim.fields import ASNField from extras.utils import extras_features from netbox.models import PrimaryModel -from utilities.querysets import RestrictedQuerySet __all__ = ( 'ProviderNetwork', @@ -87,6 +86,11 @@ class ProviderNetwork(PrimaryModel): on_delete=models.PROTECT, related_name='networks' ) + service_id = models.CharField( + max_length=100, + blank=True, + verbose_name='Service ID' + ) description = models.CharField( max_length=200, blank=True diff --git a/netbox/circuits/tables.py b/netbox/circuits/tables.py index 86a55eba5..32c40f269 100644 --- a/netbox/circuits/tables.py +++ b/netbox/circuits/tables.py @@ -69,8 +69,8 @@ class ProviderNetworkTable(BaseTable): class Meta(BaseTable.Meta): model = ProviderNetwork - fields = ('pk', 'id', 'name', 'provider', 'description', 'comments', 'tags') - default_columns = ('pk', 'name', 'provider', 'description') + fields = ('pk', 'id', 'name', 'provider', 'service_id', 'description', 'comments', 'tags') + default_columns = ('pk', 'name', 'provider', 'service_id', 'description') # diff --git a/netbox/templates/circuits/providernetwork.html b/netbox/templates/circuits/providernetwork.html index 970cd4a54..d1c513f98 100644 --- a/netbox/templates/circuits/providernetwork.html +++ b/netbox/templates/circuits/providernetwork.html @@ -28,6 +28,10 @@