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

Initial work on #6732

This commit is contained in:
Daniel Sheppard
2021-10-24 23:42:47 -05:00
parent 8c058dcd45
commit a01068949c
29 changed files with 515 additions and 38 deletions

View File

@ -8,6 +8,7 @@ from django.db.models import F, Q
from django.urls import reverse
from django.utils.functional import cached_property
from dcim.fields import ASNField
from dcim.models import Device
from extras.utils import extras_features
from netbox.models import OrganizationalModel, PrimaryModel
@ -23,6 +24,7 @@ from virtualization.models import VirtualMachine
__all__ = (
'Aggregate',
'ASN',
'IPAddress',
'IPRange',
'Prefix',
@ -69,6 +71,52 @@ class RIR(OrganizationalModel):
return reverse('ipam:rir', args=[self.pk])
class ASN(PrimaryModel):
asn = ASNField(
blank=True,
null=True,
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,
related_name='asns',
blank=False,
null=False
)
tenant = models.ForeignKey(
to='tenancy.Tenant',
on_delete=models.PROTECT,
related_name='asns',
blank=True,
null=True
)
sites = models.ManyToManyField(
to='dcim.Site',
related_name='asns',
blank=True
)
objects = RestrictedQuerySet.as_manager()
class Meta:
ordering = ['asn']
verbose_name = 'ASN'
verbose_name_plural = 'ASNs'
def __str__(self):
return f'AS{self.asn}'
def get_absolute_url(self):
return reverse('ipam:asn', args=[self.pk])
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
class Aggregate(PrimaryModel):
"""