diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index dac6119aa..8a2275a65 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -7,6 +7,7 @@ * [#8246](https://github.com/netbox-community/netbox/issues/8246) - Show human-friendly values for commit rates in circuits table * [#8262](https://github.com/netbox-community/netbox/issues/8262) - Add cable count to tenant stats * [#8265](https://github.com/netbox-community/netbox/issues/8265) - Add Stackwise-n interface types +* [#8293](https://github.com/netbox-community/netbox/issues/8293) - Show 4-byte ASNs in ASDOT notation * [#8302](https://github.com/netbox-community/netbox/issues/8302) - Linkify role column in device & VM tables ### Bug Fixes diff --git a/netbox/ipam/models/ip.py b/netbox/ipam/models/ip.py index 5cce88481..81c3ef34a 100644 --- a/netbox/ipam/models/ip.py +++ b/netbox/ipam/models/ip.py @@ -130,9 +130,20 @@ class ASN(PrimaryModel): def get_absolute_url(self): return reverse('ipam:asn', args=[self.pk]) + @property + def asn_asdot(self): + """ + Return ASDOT notation for AS numbers greater than 16 bits. + """ + if self.asn > 65535: + return f'{self.asn // 65536}.{self.asn % 65536}' + return self.asn + @property def asn_with_asdot(self): - # Return asn with asdot notation for an ASN larger than 65535 otherwise return the plain ASN + """ + Return both plain and ASDOT notation, where applicable. + """ if self.asn > 65535: return f'{self.asn} ({self.asn // 65536}.{self.asn % 65536})' else: diff --git a/netbox/ipam/tables/ip.py b/netbox/ipam/tables/ip.py index 8efb1caf3..0f43aecb8 100644 --- a/netbox/ipam/tables/ip.py +++ b/netbox/ipam/tables/ip.py @@ -104,12 +104,10 @@ class RIRTable(BaseTable): class ASNTable(BaseTable): pk = ToggleColumn() asn = tables.Column( + accessor=tables.A('asn_asdot'), linkify=True ) - def render_asn(self, value, record): - return record.asn_with_asdot - site_count = LinkedCountColumn( viewname='dcim:site_list', url_params={'asn_id': 'pk'},