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

#6732: Add asns relationship to SiteSerializer and extend tests

This commit is contained in:
jeremystretch
2021-11-03 15:15:14 -04:00
parent 7a97d5d4eb
commit 7a55832a22
6 changed files with 40 additions and 44 deletions

View File

@@ -23,7 +23,6 @@ from .nested_serializers import *
class ASNSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='ipam-api:asn-detail')
tenant = NestedTenantSerializer(required=False, allow_null=True)
site_count = serializers.IntegerField(read_only=True)
class Meta:

View File

@@ -73,11 +73,12 @@ class RIR(OrganizationalModel):
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
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.
"""
asn = ASNField(
unique=True,
blank=False,
null=False,
verbose_name='ASN',
help_text='32-bit autonomous system number'
)
@@ -89,8 +90,7 @@ class ASN(PrimaryModel):
to='ipam.RIR',
on_delete=models.PROTECT,
related_name='asns',
blank=False,
null=False
verbose_name='RIR'
)
tenant = models.ForeignKey(
to='tenancy.Tenant',