Closes #10545: Standardize description & comment fields on primary models (#10834)

* Standardize description & comments fields on primary models

* Update REST API serializers

* Update forms

* Update tables

* Update templates
This commit is contained in:
Jeremy Stretch
2022-11-04 08:28:09 -04:00
committed by GitHub
parent e2f5ee661a
commit bc6b5bc4be
105 changed files with 1014 additions and 534 deletions

View File

@@ -31,8 +31,8 @@ class ASNSerializer(NetBoxModelSerializer):
class Meta:
model = ASN
fields = [
'id', 'url', 'display', 'asn', 'rir', 'tenant', 'description', 'site_count', 'provider_count', 'tags',
'custom_fields', 'created', 'last_updated',
'id', 'url', 'display', 'asn', 'rir', 'tenant', 'description', 'comments', 'tags', 'custom_fields',
'created', 'last_updated', 'site_count', 'provider_count',
]
@@ -61,8 +61,9 @@ class VRFSerializer(NetBoxModelSerializer):
class Meta:
model = VRF
fields = [
'id', 'url', 'display', 'name', 'rd', 'tenant', 'enforce_unique', 'description', 'import_targets',
'export_targets', 'tags', 'custom_fields', 'created', 'last_updated', 'ipaddress_count', 'prefix_count',
'id', 'url', 'display', 'name', 'rd', 'tenant', 'enforce_unique', 'description', 'comments',
'import_targets', 'export_targets', 'tags', 'custom_fields', 'created', 'last_updated', 'ipaddress_count',
'prefix_count',
]
@@ -77,7 +78,8 @@ class RouteTargetSerializer(NetBoxModelSerializer):
class Meta:
model = RouteTarget
fields = [
'id', 'url', 'display', 'name', 'tenant', 'description', 'tags', 'custom_fields', 'created', 'last_updated',
'id', 'url', 'display', 'name', 'tenant', 'description', 'comments', 'tags', 'custom_fields', 'created',
'last_updated',
]
@@ -106,8 +108,8 @@ class AggregateSerializer(NetBoxModelSerializer):
class Meta:
model = Aggregate
fields = [
'id', 'url', 'display', 'family', 'prefix', 'rir', 'tenant', 'date_added', 'description', 'tags',
'custom_fields', 'created', 'last_updated',
'id', 'url', 'display', 'family', 'prefix', 'rir', 'tenant', 'date_added', 'description', 'comments',
'tags', 'custom_fields', 'created', 'last_updated',
]
read_only_fields = ['family']
@@ -123,8 +125,8 @@ class FHRPGroupSerializer(NetBoxModelSerializer):
class Meta:
model = FHRPGroup
fields = [
'id', 'name', 'url', 'display', 'protocol', 'group_id', 'auth_type', 'auth_key', 'description', 'ip_addresses',
'tags', 'custom_fields', 'created', 'last_updated',
'id', 'name', 'url', 'display', 'protocol', 'group_id', 'auth_type', 'auth_key', 'description', 'comments',
'tags', 'custom_fields', 'created', 'last_updated', 'ip_addresses',
]
@@ -215,7 +217,7 @@ class VLANSerializer(NetBoxModelSerializer):
model = VLAN
fields = [
'id', 'url', 'display', 'site', 'group', 'vid', 'name', 'tenant', 'status', 'role', 'description',
'l2vpn_termination', 'tags', 'custom_fields', 'created', 'last_updated', 'prefix_count',
'comments', 'l2vpn_termination', 'tags', 'custom_fields', 'created', 'last_updated', 'prefix_count',
]
@@ -273,7 +275,8 @@ class PrefixSerializer(NetBoxModelSerializer):
model = Prefix
fields = [
'id', 'url', 'display', 'family', 'prefix', 'site', 'vrf', 'tenant', 'vlan', 'status', 'role', 'is_pool',
'mark_utilized', 'description', 'tags', 'custom_fields', 'created', 'last_updated', 'children', '_depth',
'mark_utilized', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'children',
'_depth',
]
read_only_fields = ['family']
@@ -342,7 +345,7 @@ class IPRangeSerializer(NetBoxModelSerializer):
model = IPRange
fields = [
'id', 'url', 'display', 'family', 'start_address', 'end_address', 'size', 'vrf', 'tenant', 'status', 'role',
'description', 'tags', 'custom_fields', 'created', 'last_updated', 'children',
'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'children',
]
read_only_fields = ['family']
@@ -371,8 +374,8 @@ class IPAddressSerializer(NetBoxModelSerializer):
model = IPAddress
fields = [
'id', 'url', 'display', 'family', 'address', 'vrf', 'tenant', 'status', 'role', 'assigned_object_type',
'assigned_object_id', 'assigned_object', 'nat_inside', 'nat_outside', 'dns_name', 'description', 'tags',
'custom_fields', 'created', 'last_updated',
'assigned_object_id', 'assigned_object', 'nat_inside', 'nat_outside', 'dns_name', 'description', 'comments',
'tags', 'custom_fields', 'created', 'last_updated',
]
@swagger_serializer_method(serializer_or_field=serializers.JSONField)
@@ -415,8 +418,8 @@ class ServiceTemplateSerializer(NetBoxModelSerializer):
class Meta:
model = ServiceTemplate
fields = [
'id', 'url', 'display', 'name', 'ports', 'protocol', 'description', 'tags', 'custom_fields', 'created',
'last_updated',
'id', 'url', 'display', 'name', 'ports', 'protocol', 'description', 'comments', 'tags', 'custom_fields',
'created', 'last_updated',
]
@@ -436,7 +439,7 @@ class ServiceSerializer(NetBoxModelSerializer):
model = Service
fields = [
'id', 'url', 'display', 'device', 'virtual_machine', 'name', 'ports', 'protocol', 'ipaddresses',
'description', 'tags', 'custom_fields', 'created', 'last_updated',
'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
]
#
@@ -465,7 +468,7 @@ class L2VPNSerializer(NetBoxModelSerializer):
model = L2VPN
fields = [
'id', 'url', 'display', 'identifier', 'name', 'slug', 'type', 'import_targets', 'export_targets',
'description', 'tenant', 'tags', 'custom_fields', 'created', 'last_updated'
'description', 'comments', 'tenant', 'tags', 'custom_fields', 'created', 'last_updated'
]

View File

@@ -8,8 +8,8 @@ from ipam.models import ASN
from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant
from utilities.forms import (
add_blank_choice, BulkEditNullBooleanSelect, DynamicModelChoiceField, NumericArrayField, StaticSelect,
DynamicModelMultipleChoiceField,
add_blank_choice, BulkEditNullBooleanSelect, CommentField, DynamicModelChoiceField, NumericArrayField,
SmallTextarea, StaticSelect, DynamicModelMultipleChoiceField,
)
__all__ = (
@@ -43,15 +43,19 @@ class VRFBulkEditForm(NetBoxModelBulkEditForm):
label='Enforce unique space'
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = VRF
fieldsets = (
(None, ('tenant', 'enforce_unique', 'description')),
)
nullable_fields = ('tenant', 'description')
nullable_fields = ('tenant', 'description', 'comments')
class RouteTargetBulkEditForm(NetBoxModelBulkEditForm):
@@ -63,12 +67,16 @@ class RouteTargetBulkEditForm(NetBoxModelBulkEditForm):
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = RouteTarget
fieldsets = (
(None, ('tenant', 'description')),
)
nullable_fields = ('tenant', 'description')
nullable_fields = ('tenant', 'description', 'comments')
class RIRBulkEditForm(NetBoxModelBulkEditForm):
@@ -103,15 +111,19 @@ class ASNBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = ASN
fieldsets = (
(None, ('sites', 'rir', 'tenant', 'description')),
)
nullable_fields = ('date_added', 'description')
nullable_fields = ('date_added', 'description', 'comments')
class AggregateBulkEditForm(NetBoxModelBulkEditForm):
@@ -128,15 +140,19 @@ class AggregateBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = Aggregate
fieldsets = (
(None, ('rir', 'tenant', 'date_added', 'description')),
)
nullable_fields = ('date_added', 'description')
nullable_fields = ('date_added', 'description', 'comments')
class RoleBulkEditForm(NetBoxModelBulkEditForm):
@@ -206,9 +222,13 @@ class PrefixBulkEditForm(NetBoxModelBulkEditForm):
label='Treat as 100% utilized'
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = Prefix
fieldsets = (
@@ -217,7 +237,7 @@ class PrefixBulkEditForm(NetBoxModelBulkEditForm):
('Addressing', ('vrf', 'prefix_length', 'is_pool', 'mark_utilized')),
)
nullable_fields = (
'site', 'vrf', 'tenant', 'role', 'description',
'site', 'vrf', 'tenant', 'role', 'description', 'comments',
)
@@ -241,16 +261,20 @@ class IPRangeBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = IPRange
fieldsets = (
(None, ('status', 'role', 'vrf', 'tenant', 'description')),
)
nullable_fields = (
'vrf', 'tenant', 'role', 'description',
'vrf', 'tenant', 'role', 'description', 'comments',
)
@@ -285,9 +309,13 @@ class IPAddressBulkEditForm(NetBoxModelBulkEditForm):
label='DNS name'
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = IPAddress
fieldsets = (
@@ -295,7 +323,7 @@ class IPAddressBulkEditForm(NetBoxModelBulkEditForm):
('Addressing', ('vrf', 'mask_length', 'dns_name')),
)
nullable_fields = (
'vrf', 'role', 'tenant', 'dns_name', 'description',
'vrf', 'role', 'tenant', 'dns_name', 'description', 'comments',
)
@@ -329,13 +357,17 @@ class FHRPGroupBulkEditForm(NetBoxModelBulkEditForm):
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = FHRPGroup
fieldsets = (
(None, ('protocol', 'group_id', 'name', 'description')),
('Authentication', ('auth_type', 'auth_key')),
)
nullable_fields = ('auth_type', 'auth_key', 'name', 'description')
nullable_fields = ('auth_type', 'auth_key', 'name', 'description', 'comments')
class VLANGroupBulkEditForm(NetBoxModelBulkEditForm):
@@ -405,9 +437,13 @@ class VLANBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = VLAN
fieldsets = (
@@ -415,7 +451,7 @@ class VLANBulkEditForm(NetBoxModelBulkEditForm):
('Site & Group', ('region', 'site_group', 'site', 'group')),
)
nullable_fields = (
'site', 'group', 'tenant', 'role', 'description',
'site', 'group', 'tenant', 'role', 'description', 'comments',
)
@@ -433,15 +469,19 @@ class ServiceTemplateBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = ServiceTemplate
fieldsets = (
(None, ('protocol', 'ports', 'description')),
)
nullable_fields = ('description',)
nullable_fields = ('description', 'comments')
class ServiceBulkEditForm(ServiceTemplateBulkEditForm):
@@ -459,15 +499,19 @@ class L2VPNBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = L2VPN
fieldsets = (
(None, ('type', 'description', 'tenant')),
(None, ('type', 'tenant', 'description')),
)
nullable_fields = ('tenant', 'description',)
nullable_fields = ('tenant', 'description', 'comments')
class L2VPNTerminationBulkEditForm(NetBoxModelBulkEditForm):

View File

@@ -41,7 +41,7 @@ class VRFCSVForm(NetBoxModelCSVForm):
class Meta:
model = VRF
fields = ('name', 'rd', 'tenant', 'enforce_unique', 'description')
fields = ('name', 'rd', 'tenant', 'enforce_unique', 'description', 'comments')
class RouteTargetCSVForm(NetBoxModelCSVForm):
@@ -54,7 +54,7 @@ class RouteTargetCSVForm(NetBoxModelCSVForm):
class Meta:
model = RouteTarget
fields = ('name', 'description', 'tenant')
fields = ('name', 'tenant', 'description', 'comments')
class RIRCSVForm(NetBoxModelCSVForm):
@@ -83,7 +83,7 @@ class AggregateCSVForm(NetBoxModelCSVForm):
class Meta:
model = Aggregate
fields = ('prefix', 'rir', 'tenant', 'date_added', 'description')
fields = ('prefix', 'rir', 'tenant', 'date_added', 'description', 'comments')
class ASNCSVForm(NetBoxModelCSVForm):
@@ -101,7 +101,7 @@ class ASNCSVForm(NetBoxModelCSVForm):
class Meta:
model = ASN
fields = ('asn', 'rir', 'tenant', 'description')
fields = ('asn', 'rir', 'tenant', 'description', 'comments')
help_texts = {}
@@ -159,7 +159,7 @@ class PrefixCSVForm(NetBoxModelCSVForm):
model = Prefix
fields = (
'prefix', 'vrf', 'tenant', 'site', 'vlan_group', 'vlan', 'status', 'role', 'is_pool', 'mark_utilized',
'description',
'description', 'comments',
)
def __init__(self, data=None, *args, **kwargs):
@@ -204,7 +204,7 @@ class IPRangeCSVForm(NetBoxModelCSVForm):
class Meta:
model = IPRange
fields = (
'start_address', 'end_address', 'vrf', 'tenant', 'status', 'role', 'description',
'start_address', 'end_address', 'vrf', 'tenant', 'status', 'role', 'description', 'comments',
)
@@ -257,7 +257,7 @@ class IPAddressCSVForm(NetBoxModelCSVForm):
model = IPAddress
fields = [
'address', 'vrf', 'tenant', 'status', 'role', 'device', 'virtual_machine', 'interface', 'is_primary',
'dns_name', 'description',
'dns_name', 'description', 'comments',
]
def __init__(self, data=None, *args, **kwargs):
@@ -326,7 +326,7 @@ class FHRPGroupCSVForm(NetBoxModelCSVForm):
class Meta:
model = FHRPGroup
fields = ('protocol', 'group_id', 'auth_type', 'auth_key', 'name', 'description')
fields = ('protocol', 'group_id', 'auth_type', 'auth_key', 'name', 'description', 'comments')
class VLANGroupCSVForm(NetBoxModelCSVForm):
@@ -389,7 +389,7 @@ class VLANCSVForm(NetBoxModelCSVForm):
class Meta:
model = VLAN
fields = ('site', 'group', 'vid', 'name', 'tenant', 'status', 'role', 'description')
fields = ('site', 'group', 'vid', 'name', 'tenant', 'status', 'role', 'description', 'comments')
help_texts = {
'vid': 'Numeric VLAN ID (1-4094)',
'name': 'VLAN name',
@@ -404,7 +404,7 @@ class ServiceTemplateCSVForm(NetBoxModelCSVForm):
class Meta:
model = ServiceTemplate
fields = ('name', 'protocol', 'ports', 'description')
fields = ('name', 'protocol', 'ports', 'description', 'comments')
class ServiceCSVForm(NetBoxModelCSVForm):
@@ -427,7 +427,7 @@ class ServiceCSVForm(NetBoxModelCSVForm):
class Meta:
model = Service
fields = ('device', 'virtual_machine', 'name', 'protocol', 'ports', 'description')
fields = ('device', 'virtual_machine', 'name', 'protocol', 'ports', 'description', 'comments')
class L2VPNCSVForm(NetBoxModelCSVForm):
@@ -443,7 +443,7 @@ class L2VPNCSVForm(NetBoxModelCSVForm):
class Meta:
model = L2VPN
fields = ('identifier', 'name', 'slug', 'type', 'description')
fields = ('identifier', 'name', 'slug', 'type', 'description', 'comments')
class L2VPNTerminationCSVForm(NetBoxModelCSVForm):

View File

@@ -11,7 +11,7 @@ from netbox.forms import NetBoxModelForm
from tenancy.forms import TenancyForm
from utilities.exceptions import PermissionsViolation
from utilities.forms import (
add_blank_choice, BootstrapMixin, ContentTypeChoiceField, DatePicker, DynamicModelChoiceField,
add_blank_choice, BootstrapMixin, CommentField, ContentTypeChoiceField, DatePicker, DynamicModelChoiceField,
DynamicModelMultipleChoiceField, NumericArrayField, SlugField, StaticSelect, StaticSelectMultiple,
)
from virtualization.models import Cluster, ClusterGroup, VirtualMachine, VMInterface
@@ -49,6 +49,7 @@ class VRFForm(TenancyForm, NetBoxModelForm):
queryset=RouteTarget.objects.all(),
required=False
)
comments = CommentField()
fieldsets = (
('VRF', ('name', 'rd', 'enforce_unique', 'description', 'tags')),
@@ -59,8 +60,8 @@ class VRFForm(TenancyForm, NetBoxModelForm):
class Meta:
model = VRF
fields = [
'name', 'rd', 'enforce_unique', 'description', 'import_targets', 'export_targets', 'tenant_group', 'tenant',
'tags',
'name', 'rd', 'enforce_unique', 'import_targets', 'export_targets', 'tenant_group', 'tenant', 'description',
'comments', 'tags',
]
labels = {
'rd': "RD",
@@ -75,11 +76,12 @@ class RouteTargetForm(TenancyForm, NetBoxModelForm):
('Route Target', ('name', 'description', 'tags')),
('Tenancy', ('tenant_group', 'tenant')),
)
comments = CommentField()
class Meta:
model = RouteTarget
fields = [
'name', 'description', 'tenant_group', 'tenant', 'tags',
'name', 'tenant_group', 'tenant', 'description', 'comments', 'tags',
]
@@ -104,6 +106,7 @@ class AggregateForm(TenancyForm, NetBoxModelForm):
queryset=RIR.objects.all(),
label='RIR'
)
comments = CommentField()
fieldsets = (
('Aggregate', ('prefix', 'rir', 'date_added', 'description', 'tags')),
@@ -113,7 +116,7 @@ class AggregateForm(TenancyForm, NetBoxModelForm):
class Meta:
model = Aggregate
fields = [
'prefix', 'rir', 'date_added', 'description', 'tenant_group', 'tenant', 'tags',
'prefix', 'rir', 'date_added', 'tenant_group', 'tenant', 'description', 'comments', 'tags',
]
help_texts = {
'prefix': "IPv4 or IPv6 network",
@@ -134,6 +137,7 @@ class ASNForm(TenancyForm, NetBoxModelForm):
label='Sites',
required=False
)
comments = CommentField()
fieldsets = (
('ASN', ('asn', 'rir', 'sites', 'description', 'tags')),
@@ -143,7 +147,7 @@ class ASNForm(TenancyForm, NetBoxModelForm):
class Meta:
model = ASN
fields = [
'asn', 'rir', 'sites', 'tenant_group', 'tenant', 'description', 'tags'
'asn', 'rir', 'sites', 'tenant_group', 'tenant', 'description', 'comments', 'tags'
]
help_texts = {
'asn': "AS number",
@@ -235,6 +239,7 @@ class PrefixForm(TenancyForm, NetBoxModelForm):
queryset=Role.objects.all(),
required=False
)
comments = CommentField()
fieldsets = (
('Prefix', ('prefix', 'status', 'vrf', 'role', 'is_pool', 'mark_utilized', 'description', 'tags')),
@@ -245,8 +250,8 @@ class PrefixForm(TenancyForm, NetBoxModelForm):
class Meta:
model = Prefix
fields = [
'prefix', 'vrf', 'site', 'vlan', 'status', 'role', 'is_pool', 'mark_utilized', 'description',
'tenant_group', 'tenant', 'tags',
'prefix', 'vrf', 'site', 'vlan', 'status', 'role', 'is_pool', 'mark_utilized', 'tenant_group', 'tenant',
'description', 'comments', 'tags',
]
widgets = {
'status': StaticSelect(),
@@ -263,6 +268,7 @@ class IPRangeForm(TenancyForm, NetBoxModelForm):
queryset=Role.objects.all(),
required=False
)
comments = CommentField()
fieldsets = (
('IP Range', ('vrf', 'start_address', 'end_address', 'role', 'status', 'description', 'tags')),
@@ -272,7 +278,8 @@ class IPRangeForm(TenancyForm, NetBoxModelForm):
class Meta:
model = IPRange
fields = [
'vrf', 'start_address', 'end_address', 'status', 'role', 'description', 'tenant_group', 'tenant', 'tags',
'vrf', 'start_address', 'end_address', 'status', 'role', 'tenant_group', 'tenant', 'description',
'comments', 'tags',
]
widgets = {
'status': StaticSelect(),
@@ -394,13 +401,14 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
required=False,
label='Make this the primary IP for the device/VM'
)
comments = CommentField()
class Meta:
model = IPAddress
fields = [
'address', 'vrf', 'status', 'role', 'dns_name', 'description', 'primary_for_parent', 'nat_site', 'nat_rack',
'nat_device', 'nat_cluster', 'nat_virtual_machine', 'nat_vrf', 'nat_inside', 'tenant_group', 'tenant',
'tags',
'address', 'vrf', 'status', 'role', 'dns_name', 'primary_for_parent', 'nat_site', 'nat_rack', 'nat_device',
'nat_cluster', 'nat_virtual_machine', 'nat_vrf', 'nat_inside', 'tenant_group', 'tenant', 'description',
'comments', 'tags',
]
widgets = {
'status': StaticSelect(),
@@ -535,6 +543,7 @@ class FHRPGroupForm(NetBoxModelForm):
required=False,
label='Status'
)
comments = CommentField()
fieldsets = (
('FHRP Group', ('protocol', 'group_id', 'name', 'description', 'tags')),
@@ -545,7 +554,8 @@ class FHRPGroupForm(NetBoxModelForm):
class Meta:
model = FHRPGroup
fields = (
'protocol', 'group_id', 'auth_type', 'auth_key', 'name', 'description', 'ip_vrf', 'ip_address', 'ip_status', 'tags',
'protocol', 'group_id', 'auth_type', 'auth_key', 'name', 'ip_vrf', 'ip_address', 'ip_status', 'description',
'comments', 'tags',
)
def save(self, *args, **kwargs):
@@ -767,11 +777,13 @@ class VLANForm(TenancyForm, NetBoxModelForm):
queryset=Role.objects.all(),
required=False
)
comments = CommentField()
class Meta:
model = VLAN
fields = [
'site', 'group', 'vid', 'name', 'status', 'role', 'description', 'tenant_group', 'tenant', 'tags',
'site', 'group', 'vid', 'name', 'status', 'role', 'tenant_group', 'tenant', 'description', 'comments',
'tags',
]
help_texts = {
'site': "Leave blank if this VLAN spans multiple sites",
@@ -794,6 +806,7 @@ class ServiceTemplateForm(NetBoxModelForm):
),
help_text="Comma-separated list of one or more port numbers. A range may be specified using a hyphen."
)
comments = CommentField()
fieldsets = (
('Service Template', (
@@ -803,7 +816,7 @@ class ServiceTemplateForm(NetBoxModelForm):
class Meta:
model = ServiceTemplate
fields = ('name', 'protocol', 'ports', 'description', 'tags')
fields = ('name', 'protocol', 'ports', 'description', 'comments', 'tags')
widgets = {
'protocol': StaticSelect(),
}
@@ -834,11 +847,12 @@ class ServiceForm(NetBoxModelForm):
'virtual_machine_id': '$virtual_machine',
}
)
comments = CommentField()
class Meta:
model = Service
fields = [
'device', 'virtual_machine', 'name', 'protocol', 'ports', 'ipaddresses', 'description', 'tags',
'device', 'virtual_machine', 'name', 'protocol', 'ports', 'ipaddresses', 'description', 'comments', 'tags',
]
help_texts = {
'ipaddresses': "IP address assignment is optional. If no IPs are selected, the service is assumed to be "
@@ -899,6 +913,7 @@ class L2VPNForm(TenancyForm, NetBoxModelForm):
queryset=RouteTarget.objects.all(),
required=False
)
comments = CommentField()
fieldsets = (
('L2VPN', ('name', 'slug', 'type', 'identifier', 'description', 'tags')),
@@ -909,7 +924,8 @@ class L2VPNForm(TenancyForm, NetBoxModelForm):
class Meta:
model = L2VPN
fields = (
'name', 'slug', 'type', 'identifier', 'description', 'import_targets', 'export_targets', 'tenant', 'tags'
'name', 'slug', 'type', 'identifier', 'import_targets', 'export_targets', 'tenant', 'description',
'comments', 'tags'
)
widgets = {
'type': StaticSelect(),

View File

@@ -0,0 +1,73 @@
# Generated by Django 4.1.2 on 2022-11-03 18:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ipam', '0062_unique_constraints'),
]
operations = [
migrations.AddField(
model_name='aggregate',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='asn',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='fhrpgroup',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='ipaddress',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='iprange',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='l2vpn',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='prefix',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='routetarget',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='service',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='servicetemplate',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='vlan',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='vrf',
name='comments',
field=models.TextField(blank=True),
),
]

View File

@@ -4,7 +4,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.urls import reverse
from netbox.models import ChangeLoggedModel, NetBoxModel
from netbox.models import ChangeLoggedModel, PrimaryModel
from netbox.models.features import WebhooksMixin
from ipam.choices import *
from ipam.constants import *
@@ -15,7 +15,7 @@ __all__ = (
)
class FHRPGroup(NetBoxModel):
class FHRPGroup(PrimaryModel):
"""
A grouping of next hope resolution protocol (FHRP) peers. (For instance, VRRP or HSRP.)
"""
@@ -41,10 +41,6 @@ class FHRPGroup(NetBoxModel):
blank=True,
verbose_name='Authentication key'
)
description = models.CharField(
max_length=200,
blank=True
)
ip_addresses = GenericRelation(
to='ipam.IPAddress',
content_type_field='assigned_object_type',

View File

@@ -9,7 +9,7 @@ from django.utils.functional import cached_property
from dcim.fields import ASNField
from dcim.models import Device
from netbox.models import OrganizationalModel, NetBoxModel
from netbox.models import OrganizationalModel, PrimaryModel
from ipam.choices import *
from ipam.constants import *
from ipam.fields import IPNetworkField, IPAddressField
@@ -76,7 +76,7 @@ class RIR(OrganizationalModel):
return reverse('ipam:rir', args=[self.pk])
class ASN(NetBoxModel):
class ASN(PrimaryModel):
"""
An autonomous system (AS) number is typically used to represent an independent routing domain. A site can have
one or more ASNs assigned to it.
@@ -86,10 +86,6 @@ class ASN(NetBoxModel):
verbose_name='ASN',
help_text='32-bit autonomous system number'
)
description = models.CharField(
max_length=200,
blank=True
)
rir = models.ForeignKey(
to='ipam.RIR',
on_delete=models.PROTECT,
@@ -139,7 +135,7 @@ class ASN(NetBoxModel):
return self.asn
class Aggregate(GetAvailablePrefixesMixin, NetBoxModel):
class Aggregate(GetAvailablePrefixesMixin, PrimaryModel):
"""
An aggregate exists at the root level of the IP address space hierarchy in NetBox. Aggregates are used to organize
the hierarchy and track the overall utilization of available address space. Each Aggregate is assigned to a RIR.
@@ -162,10 +158,6 @@ class Aggregate(GetAvailablePrefixesMixin, NetBoxModel):
blank=True,
null=True
)
description = models.CharField(
max_length=200,
blank=True
)
clone_fields = (
'rir', 'tenant', 'date_added', 'description',
@@ -264,7 +256,7 @@ class Role(OrganizationalModel):
return reverse('ipam:role', args=[self.pk])
class Prefix(GetAvailablePrefixesMixin, NetBoxModel):
class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
"""
A Prefix represents an IPv4 or IPv6 network, including mask length. Prefixes can optionally be assigned to Sites and
VRFs. A Prefix must be assigned a status and may optionally be assigned a used-define Role. A Prefix can also be
@@ -327,10 +319,6 @@ class Prefix(GetAvailablePrefixesMixin, NetBoxModel):
default=False,
help_text="Treat as 100% utilized"
)
description = models.CharField(
max_length=200,
blank=True
)
# Cached depth & child counts
_depth = models.PositiveSmallIntegerField(
@@ -545,7 +533,7 @@ class Prefix(GetAvailablePrefixesMixin, NetBoxModel):
return min(utilization, 100)
class IPRange(NetBoxModel):
class IPRange(PrimaryModel):
"""
A range of IP addresses, defined by start and end addresses.
"""
@@ -587,10 +575,6 @@ class IPRange(NetBoxModel):
null=True,
help_text='The primary function of this range'
)
description = models.CharField(
max_length=200,
blank=True
)
clone_fields = (
'vrf', 'tenant', 'status', 'role', 'description',
@@ -740,7 +724,7 @@ class IPRange(NetBoxModel):
return int(float(child_count) / self.size * 100)
class IPAddress(NetBoxModel):
class IPAddress(PrimaryModel):
"""
An IPAddress represents an individual IPv4 or IPv6 address and its mask. The mask length should match what is
configured in the real world. (Typically, only loopback interfaces are configured with /32 or /128 masks.) Like
@@ -813,10 +797,6 @@ class IPAddress(NetBoxModel):
verbose_name='DNS Name',
help_text='Hostname or FQDN (not case-sensitive)'
)
description = models.CharField(
max_length=200,
blank=True
)
objects = IPAddressManager()

View File

@@ -8,7 +8,7 @@ from django.utils.functional import cached_property
from ipam.choices import L2VPNTypeChoices
from ipam.constants import L2VPN_ASSIGNMENT_MODELS
from netbox.models import NetBoxModel
from netbox.models import NetBoxModel, PrimaryModel
__all__ = (
'L2VPN',
@@ -16,7 +16,7 @@ __all__ = (
)
class L2VPN(NetBoxModel):
class L2VPN(PrimaryModel):
name = models.CharField(
max_length=100,
unique=True
@@ -43,10 +43,6 @@ class L2VPN(NetBoxModel):
related_name='exporting_l2vpns',
blank=True
)
description = models.CharField(
max_length=200,
blank=True
)
tenant = models.ForeignKey(
to='tenancy.Tenant',
on_delete=models.PROTECT,

View File

@@ -6,7 +6,7 @@ from django.urls import reverse
from ipam.choices import *
from ipam.constants import *
from netbox.models import NetBoxModel
from netbox.models import PrimaryModel
from utilities.utils import array_to_string
@@ -30,10 +30,6 @@ class ServiceBase(models.Model):
),
verbose_name='Port numbers'
)
description = models.CharField(
max_length=200,
blank=True
)
class Meta:
abstract = True
@@ -46,7 +42,7 @@ class ServiceBase(models.Model):
return array_to_string(self.ports)
class ServiceTemplate(ServiceBase, NetBoxModel):
class ServiceTemplate(ServiceBase, PrimaryModel):
"""
A template for a Service to be applied to a device or virtual machine.
"""
@@ -62,7 +58,7 @@ class ServiceTemplate(ServiceBase, NetBoxModel):
return reverse('ipam:servicetemplate', args=[self.pk])
class Service(ServiceBase, NetBoxModel):
class Service(ServiceBase, PrimaryModel):
"""
A Service represents a layer-four service (e.g. HTTP or SSH) running on a Device or VirtualMachine. A Service may
optionally be tied to one or more specific IPAddresses belonging to its parent.

View File

@@ -8,12 +8,10 @@ from django.urls import reverse
from dcim.models import Interface
from ipam.choices import *
from ipam.constants import *
from ipam.models import L2VPNTermination
from ipam.querysets import VLANQuerySet
from netbox.models import OrganizationalModel, NetBoxModel
from netbox.models import OrganizationalModel, PrimaryModel
from virtualization.models import VMInterface
__all__ = (
'VLAN',
'VLANGroup',
@@ -63,10 +61,6 @@ class VLANGroup(OrganizationalModel):
),
help_text='Highest permissible ID of a child VLAN'
)
description = models.CharField(
max_length=200,
blank=True
)
class Meta:
ordering = ('name', 'pk') # Name may be non-unique
@@ -120,7 +114,7 @@ class VLANGroup(OrganizationalModel):
return None
class VLAN(NetBoxModel):
class VLAN(PrimaryModel):
"""
A VLAN is a distinct layer two forwarding domain identified by a 12-bit integer (1-4094). Each VLAN must be assigned
to a Site, however VLAN IDs need not be unique within a Site. A VLAN may optionally be assigned to a VLANGroup,
@@ -172,10 +166,6 @@ class VLAN(NetBoxModel):
blank=True,
null=True
)
description = models.CharField(
max_length=200,
blank=True
)
l2vpn_terminations = GenericRelation(
to='ipam.L2VPNTermination',

View File

@@ -2,7 +2,7 @@ from django.db import models
from django.urls import reverse
from ipam.constants import *
from netbox.models import NetBoxModel
from netbox.models import PrimaryModel
__all__ = (
@@ -11,7 +11,7 @@ __all__ = (
)
class VRF(NetBoxModel):
class VRF(PrimaryModel):
"""
A virtual routing and forwarding (VRF) table represents a discrete layer three forwarding domain (e.g. a routing
table). Prefixes and IPAddresses can optionally be assigned to VRFs. (Prefixes and IPAddresses not assigned to a VRF
@@ -40,10 +40,6 @@ class VRF(NetBoxModel):
verbose_name='Enforce unique space',
help_text='Prevent duplicate prefixes/IP addresses within this VRF'
)
description = models.CharField(
max_length=200,
blank=True
)
import_targets = models.ManyToManyField(
to='ipam.RouteTarget',
related_name='importing_vrfs',
@@ -73,7 +69,7 @@ class VRF(NetBoxModel):
return reverse('ipam:vrf', args=[self.pk])
class RouteTarget(NetBoxModel):
class RouteTarget(PrimaryModel):
"""
A BGP extended community used to control the redistribution of routes among VRFs, as defined in RFC 4364.
"""
@@ -82,10 +78,6 @@ class RouteTarget(NetBoxModel):
unique=True,
help_text='Route target value (formatted in accordance with RFC 4360)'
)
description = models.CharField(
max_length=200,
blank=True
)
tenant = models.ForeignKey(
to='tenancy.Tenant',
on_delete=models.PROTECT,

View File

@@ -20,7 +20,6 @@ class FHRPGroupTable(NetBoxTable):
group_id = tables.Column(
linkify=True
)
comments = columns.MarkdownColumn()
ip_addresses = tables.TemplateColumn(
template_code=IPADDRESSES,
orderable=False,
@@ -29,6 +28,7 @@ class FHRPGroupTable(NetBoxTable):
member_count = tables.Column(
verbose_name='Members'
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:fhrpgroup_list'
)
@@ -36,7 +36,7 @@ class FHRPGroupTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = FHRPGroup
fields = (
'pk', 'group_id', 'protocol', 'name', 'auth_type', 'auth_key', 'description', 'ip_addresses',
'pk', 'group_id', 'protocol', 'name', 'auth_type', 'auth_key', 'description', 'comments', 'ip_addresses',
'member_count', 'tags', 'created', 'last_updated',
)
default_columns = (

View File

@@ -120,6 +120,7 @@ class ASNTable(TenancyColumnsMixin, NetBoxTable):
linkify_item=True,
verbose_name='Sites'
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:asn_list'
)
@@ -127,8 +128,8 @@ class ASNTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta):
model = ASN
fields = (
'pk', 'asn', 'asn_asdot', 'rir', 'site_count', 'provider_count', 'tenant', 'tenant_group', 'description', 'sites', 'tags',
'created', 'last_updated', 'actions',
'pk', 'asn', 'asn_asdot', 'rir', 'site_count', 'provider_count', 'tenant', 'tenant_group', 'description',
'comments', 'sites', 'tags', 'created', 'last_updated', 'actions',
)
default_columns = ('pk', 'asn', 'rir', 'site_count', 'provider_count', 'sites', 'description', 'tenant')
@@ -153,6 +154,7 @@ class AggregateTable(TenancyColumnsMixin, NetBoxTable):
accessor='get_utilization',
orderable=False
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:aggregate_list'
)
@@ -160,8 +162,8 @@ class AggregateTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Aggregate
fields = (
'pk', 'id', 'prefix', 'rir', 'tenant', 'tenant_group', 'child_count', 'utilization', 'date_added', 'description', 'tags',
'created', 'last_updated',
'pk', 'id', 'prefix', 'rir', 'tenant', 'tenant_group', 'child_count', 'utilization', 'date_added',
'description', 'comments', 'tags', 'created', 'last_updated',
)
default_columns = ('pk', 'prefix', 'rir', 'tenant', 'child_count', 'utilization', 'date_added', 'description')
@@ -278,6 +280,7 @@ class PrefixTable(TenancyColumnsMixin, NetBoxTable):
accessor='get_utilization',
orderable=False
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:prefix_list'
)
@@ -285,8 +288,9 @@ class PrefixTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Prefix
fields = (
'pk', 'id', 'prefix', 'prefix_flat', 'status', 'children', 'vrf', 'utilization', 'tenant', 'tenant_group', 'site',
'vlan_group', 'vlan', 'role', 'is_pool', 'mark_utilized', 'description', 'tags', 'created', 'last_updated',
'pk', 'id', 'prefix', 'prefix_flat', 'status', 'children', 'vrf', 'utilization', 'tenant', 'tenant_group',
'site', 'vlan_group', 'vlan', 'role', 'is_pool', 'mark_utilized', 'description', 'comments', 'tags',
'created', 'last_updated',
)
default_columns = (
'pk', 'prefix', 'status', 'children', 'vrf', 'utilization', 'tenant', 'site', 'vlan', 'role', 'description',
@@ -317,6 +321,7 @@ class IPRangeTable(TenancyColumnsMixin, NetBoxTable):
accessor='utilization',
orderable=False
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:iprange_list'
)
@@ -324,8 +329,8 @@ class IPRangeTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta):
model = IPRange
fields = (
'pk', 'id', 'start_address', 'end_address', 'size', 'vrf', 'status', 'role', 'tenant', 'tenant_group', 'description',
'utilization', 'tags', 'created', 'last_updated',
'pk', 'id', 'start_address', 'end_address', 'size', 'vrf', 'status', 'role', 'tenant', 'tenant_group',
'utilization', 'description', 'comments', 'tags', 'created', 'last_updated',
)
default_columns = (
'pk', 'start_address', 'end_address', 'size', 'vrf', 'status', 'role', 'tenant', 'description',
@@ -378,6 +383,7 @@ class IPAddressTable(TenancyColumnsMixin, NetBoxTable):
linkify=lambda record: record.assigned_object.get_absolute_url(),
verbose_name='Assigned'
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:ipaddress_list'
)
@@ -385,8 +391,8 @@ class IPAddressTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta):
model = IPAddress
fields = (
'pk', 'id', 'address', 'vrf', 'status', 'role', 'tenant', 'tenant_group', 'nat_inside', 'nat_outside', 'assigned', 'dns_name', 'description',
'tags', 'created', 'last_updated',
'pk', 'id', 'address', 'vrf', 'status', 'role', 'tenant', 'tenant_group', 'nat_inside', 'nat_outside',
'assigned', 'dns_name', 'description', 'comments', 'tags', 'created', 'last_updated',
)
default_columns = (
'pk', 'address', 'vrf', 'status', 'role', 'tenant', 'assigned', 'dns_name', 'description',

View File

@@ -29,12 +29,16 @@ class L2VPNTable(TenancyColumnsMixin, NetBoxTable):
template_code=L2VPN_TARGETS,
orderable=False
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:prefix_list'
)
class Meta(NetBoxTable.Meta):
model = L2VPN
fields = (
'pk', 'name', 'slug', 'identifier', 'type', 'description', 'import_targets', 'export_targets', 'tenant', 'tenant_group',
'actions',
'pk', 'name', 'slug', 'identifier', 'type', 'import_targets', 'export_targets', 'tenant', 'tenant_group',
'description', 'comments', 'tags', 'created', 'last_updated', 'actions',
)
default_columns = ('pk', 'name', 'identifier', 'type', 'description', 'actions')

View File

@@ -17,13 +17,16 @@ class ServiceTemplateTable(NetBoxTable):
accessor=tables.A('port_list'),
order_by=tables.A('ports'),
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:servicetemplate_list'
)
class Meta(NetBoxTable.Meta):
model = ServiceTemplate
fields = ('pk', 'id', 'name', 'protocol', 'ports', 'description', 'tags')
fields = (
'pk', 'id', 'name', 'protocol', 'ports', 'description', 'comments', 'tags', 'created', 'last_updated',
)
default_columns = ('pk', 'name', 'protocol', 'ports', 'description')
@@ -39,6 +42,7 @@ class ServiceTable(NetBoxTable):
accessor=tables.A('port_list'),
order_by=tables.A('ports'),
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:service_list'
)
@@ -46,7 +50,7 @@ class ServiceTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Service
fields = (
'pk', 'id', 'name', 'parent', 'protocol', 'ports', 'ipaddresses', 'description', 'tags', 'created',
'last_updated',
'pk', 'id', 'name', 'parent', 'protocol', 'ports', 'ipaddresses', 'description', 'comments', 'tags',
'created', 'last_updated',
)
default_columns = ('pk', 'name', 'parent', 'protocol', 'ports', 'description')

View File

@@ -121,6 +121,7 @@ class VLANTable(TenancyColumnsMixin, NetBoxTable):
orderable=False,
verbose_name='Prefixes'
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:vlan_list'
)
@@ -129,7 +130,7 @@ class VLANTable(TenancyColumnsMixin, NetBoxTable):
model = VLAN
fields = (
'pk', 'id', 'vid', 'name', 'site', 'group', 'prefixes', 'tenant', 'tenant_group', 'status', 'role',
'description', 'tags', 'l2vpn', 'created', 'last_updated',
'description', 'comments', 'tags', 'l2vpn', 'created', 'last_updated',
)
default_columns = ('pk', 'vid', 'name', 'site', 'group', 'prefixes', 'tenant', 'status', 'role', 'description')
row_attrs = {

View File

@@ -38,6 +38,7 @@ class VRFTable(TenancyColumnsMixin, NetBoxTable):
template_code=VRF_TARGETS,
orderable=False
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:vrf_list'
)
@@ -45,8 +46,8 @@ class VRFTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta):
model = VRF
fields = (
'pk', 'id', 'name', 'rd', 'tenant', 'tenant_group', 'enforce_unique', 'description', 'import_targets', 'export_targets',
'tags', 'created', 'last_updated',
'pk', 'id', 'name', 'rd', 'tenant', 'tenant_group', 'enforce_unique', 'import_targets', 'export_targets',
'description', 'comments', 'tags', 'created', 'last_updated',
)
default_columns = ('pk', 'name', 'rd', 'tenant', 'description')
@@ -59,11 +60,14 @@ class RouteTargetTable(TenancyColumnsMixin, NetBoxTable):
name = tables.Column(
linkify=True
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='ipam:vrf_list'
)
class Meta(NetBoxTable.Meta):
model = RouteTarget
fields = ('pk', 'id', 'name', 'tenant', 'tenant_group', 'description', 'tags', 'created', 'last_updated',)
fields = (
'pk', 'id', 'name', 'tenant', 'tenant_group', 'description', 'comments', 'tags', 'created', 'last_updated',
)
default_columns = ('pk', 'name', 'tenant', 'description')