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

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

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