1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #7681: Add service_id field for provider networks

This commit is contained in:
jeremystretch
2021-12-23 13:50:01 -05:00
parent a03ae295f6
commit bffd22038b
12 changed files with 48 additions and 12 deletions

View File

@ -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.

View File

@ -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

View File

@ -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',
]

View File

@ -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()

View File

@ -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',
]

View File

@ -32,7 +32,7 @@ class ProviderNetworkCSVForm(CustomFieldModelCSVForm):
class Meta:
model = ProviderNetwork
fields = [
'provider', 'name', 'description', 'comments',
'provider', 'name', 'service_id', 'description', 'comments',
]

View File

@ -64,6 +64,10 @@ class ProviderNetworkFilterForm(CustomFieldModelFilterForm):
label=_('Provider'),
fetch_trigger='open'
)
service_id = forms.CharField(
max_length=100,
required=False
)
tag = TagFilterField(model)

View File

@ -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')),
)

View File

@ -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),
),
]

View File

@ -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

View File

@ -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')
#

View File

@ -28,6 +28,10 @@
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Service ID</th>
<td>{{ object.service_id|placeholder }}</td>
</tr>
<tr>
<th scope="row">Description</th>
<td>{{ object.description|placeholder }}</td>