diff --git a/netbox/ipam/models/ip.py b/netbox/ipam/models/ip.py index 9c00a9068..c92b54537 100644 --- a/netbox/ipam/models/ip.py +++ b/netbox/ipam/models/ip.py @@ -130,6 +130,14 @@ class ASN(PrimaryModel): def get_absolute_url(self): return reverse('ipam:asn', args=[self.pk]) + @property + def asdot_notation(self): + # Return asdot notation for an ASN larger than 65535 + if self.asn > 65535: + return '{}.{}'.format(self.asn // 65536, self.asn % 65536) + else: + return None + @extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks') class Aggregate(GetAvailablePrefixesMixin, PrimaryModel): diff --git a/netbox/ipam/tables/ip.py b/netbox/ipam/tables/ip.py index 3fddbf48e..988c89aa2 100644 --- a/netbox/ipam/tables/ip.py +++ b/netbox/ipam/tables/ip.py @@ -106,6 +106,13 @@ class ASNTable(BaseTable): asn = tables.Column( linkify=True ) + + def render_asn(self, value, record): + if record.asdot_notation: + return f'{value} ({record.asdot_notation})' + else: + return value + site_count = LinkedCountColumn( viewname='dcim:site_list', url_params={'asn_id': 'pk'}, diff --git a/netbox/templates/ipam/asn.html b/netbox/templates/ipam/asn.html index 53afd5ebb..85eaf8122 100644 --- a/netbox/templates/ipam/asn.html +++ b/netbox/templates/ipam/asn.html @@ -18,7 +18,7 @@ - +
AS Number{{ object.asn }}{{ object.asn }} {% if object.asdot_notation %}({{ object.asdot_notation }}){% endif %}
RIR