Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion netbox/ipam/models/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,19 @@ class Meta:
verbose_name_plural = 'ASNs'

def __str__(self):
return f'AS{self.asn}'
return f'AS{self.asn_with_asdot}'

def get_absolute_url(self):
return reverse('ipam:asn', args=[self.pk])

@property
def asn_with_asdot(self):
# Return asn with asdot notation for an ASN larger than 65535 otherwise return the plain ASN
if self.asn > 65535:
return f'{self.asn} ({self.asn // 65536}.{self.asn % 65536})'
else:
return self.asn


@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
class Aggregate(GetAvailablePrefixesMixin, PrimaryModel):
Expand Down
4 changes: 4 additions & 0 deletions netbox/ipam/tables/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class ASNTable(BaseTable):
asn = tables.Column(
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'},
Expand Down
2 changes: 1 addition & 1 deletion netbox/templates/ipam/asn.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h5 class="card-header">ASN</h5>
<table class="table table-hover attr-table">
<tr>
<td>AS Number</td>
<td>{{ object.asn }}</td>
<td>{{ object.asn_with_asdot }}</td>
</tr>
<tr>
<td>RIR</td>
Expand Down