diff --git a/netbox/ipam/tables.py b/netbox/ipam/tables.py index 922ce6a5c..1877c82fd 100644 --- a/netbox/ipam/tables.py +++ b/netbox/ipam/tables.py @@ -127,11 +127,16 @@ class RIRTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn(verbose_name='Name') aggregate_count = tables.Column(verbose_name='Aggregates') - stats_total = tables.Column(accessor='stats.total', verbose_name='Total') - stats_active = tables.Column(accessor='stats.active', verbose_name='Active') - stats_reserved = tables.Column(accessor='stats.reserved', verbose_name='Reserved') - stats_deprecated = tables.Column(accessor='stats.deprecated', verbose_name='Deprecated') - stats_available = tables.Column(accessor='stats.available', verbose_name='Available') + stats_total = tables.Column(accessor='stats.total', verbose_name='Total', + footer=lambda table: sum(r.stats['total'] for r in table.data)) + stats_active = tables.Column(accessor='stats.active', verbose_name='Active', + footer=lambda table: sum(r.stats['active'] for r in table.data)) + stats_reserved = tables.Column(accessor='stats.reserved', verbose_name='Reserved', + footer=lambda table: sum(r.stats['reserved'] for r in table.data)) + stats_deprecated = tables.Column(accessor='stats.deprecated', verbose_name='Deprecated', + footer=lambda table: sum(r.stats['deprecated'] for r in table.data)) + stats_available = tables.Column(accessor='stats.available', verbose_name='Available', + footer=lambda table: sum(r.stats['available'] for r in table.data)) utilization = tables.TemplateColumn(template_code=RIR_UTILIZATION, verbose_name='Utilization') actions = tables.TemplateColumn(template_code=RIR_ACTIONS, attrs={'td': {'class': 'text-right'}}, verbose_name='') diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index f804e565e..930c2de56 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -160,9 +160,12 @@ class RIRListView(ObjectListView): def alter_queryset(self, request): - # Count /64s for IPv6 rather than individual IPs - family = 4 - denominator = 2 ** 64 if family == 6 else 1 + if request.GET.get('family') == '6': + family = 6 + denominator = 2 ** 64 # Count /64s for IPv6 rather than individual IPs + else: + family = 4 + denominator = 1 rirs = [] for rir in self.queryset: diff --git a/netbox/project-static/css/base.css b/netbox/project-static/css/base.css index 635745309..635aa7e94 100644 --- a/netbox/project-static/css/base.css +++ b/netbox/project-static/css/base.css @@ -85,6 +85,9 @@ label.required { th.pk, td.pk { width: 30px; } +tfoot td { + font-weight: bold; +} /* Paginator */ nav ul.pagination { diff --git a/netbox/templates/ipam/rir_list.html b/netbox/templates/ipam/rir_list.html index f0b38ac7f..756e91d7f 100644 --- a/netbox/templates/ipam/rir_list.html +++ b/netbox/templates/ipam/rir_list.html @@ -6,6 +6,17 @@ {% block content %}
+ {% if request.GET.family == '6' %} + + + IPv4 Stats + + {% else %} + + + IPv6 Stats + + {% endif %} {% if perms.ipam.add_rir %} @@ -19,29 +30,7 @@ {% include 'utilities/obj_table.html' with bulk_delete_url='ipam:rir_bulk_delete' %}
-
-
-

Totals

-
-
-

{{ totals.total|intcomma }}

- All IPv4 space -
-
-

{{ totals.active|intcomma }}

- Active -
-
-

{{ totals.reserved|intcomma }}

- Reserved -
-
-

{{ totals.deprecated|intcomma }}

- Deprecated -
-
-

{{ totals.available|intcomma }}

- Available -
-
+{% if request.GET.family == '6' %} +
Note: Numbers shown indicate /64 prefixes.
+{% endif %} {% endblock %}