diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 821c7beec..922e2ce27 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -139,6 +139,21 @@ class AggregateListView(ObjectListView): edit_permissions = ['ipam.change_aggregate', 'ipam.delete_aggregate'] template_name = 'ipam/aggregate_list.html' + def extra_context(self): + ipv4_total = 0 + ipv6_total = 0 + + for a in self.queryset: + if a.prefix.version == 4: + ipv4_total += a.prefix.size + elif a.prefix.version == 6: + ipv6_total += a.prefix.size / 2**64 + + return { + 'ipv4_total': ipv4_total, + 'ipv6_total': ipv6_total, + } + def aggregate(request, pk): diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 55a7ab57c..e37d0b51a 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -57,6 +57,7 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.contrib.humanize', 'debug_toolbar', 'django_extensions', 'django_tables2', diff --git a/netbox/templates/ipam/aggregate_list.html b/netbox/templates/ipam/aggregate_list.html index 0945b136b..5f249741c 100644 --- a/netbox/templates/ipam/aggregate_list.html +++ b/netbox/templates/ipam/aggregate_list.html @@ -1,4 +1,5 @@ {% extends '_base.html' %} +{% load humanize %} {% load helpers %} {% block title %}Aggregates{% endblock %} @@ -29,6 +30,8 @@
IPv4 total: {{ ipv4_total|intcomma }} /32s
+IPv6 total: {{ ipv6_total|intcomma }} /64s