diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index e827ea139..9c9ab0f5a 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -4,6 +4,7 @@ ### Enhancements +* [#7504](https://github.com/netbox-community/netbox/issues/7504) - Include IP range data under IPAM role views * [#8275](https://github.com/netbox-community/netbox/issues/8275) - Introduce alternative ASDOT-formatted column for ASNs * [#8367](https://github.com/netbox-community/netbox/issues/8367) - Add ASNs to global search function * [#8368](https://github.com/netbox-community/netbox/issues/8368) - Enable controlling the order of custom script form fields with `field_order` diff --git a/netbox/ipam/tables/ip.py b/netbox/ipam/tables/ip.py index df2d97dac..9fdde2b8b 100644 --- a/netbox/ipam/tables/ip.py +++ b/netbox/ipam/tables/ip.py @@ -184,6 +184,11 @@ class RoleTable(BaseTable): url_params={'role_id': 'pk'}, verbose_name='Prefixes' ) + iprange_count = LinkedCountColumn( + viewname='ipam:iprange_list', + url_params={'role_id': 'pk'}, + verbose_name='IP Ranges' + ) vlan_count = LinkedCountColumn( viewname='ipam:vlan_list', url_params={'role_id': 'pk'}, @@ -197,10 +202,10 @@ class RoleTable(BaseTable): class Meta(BaseTable.Meta): model = Role fields = ( - 'pk', 'id', 'name', 'slug', 'prefix_count', 'vlan_count', 'description', 'weight', 'tags', 'actions', - 'created', 'last_updated', + 'pk', 'id', 'name', 'slug', 'prefix_count', 'iprange_count', 'vlan_count', 'description', 'weight', 'tags', + 'actions', 'created', 'last_updated', ) - default_columns = ('pk', 'name', 'prefix_count', 'vlan_count', 'description', 'actions') + default_columns = ('pk', 'name', 'prefix_count', 'iprange_count', 'vlan_count', 'description', 'actions') # diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 38b30e9cc..c9ac44f46 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -340,6 +340,7 @@ class AggregateBulkDeleteView(generic.BulkDeleteView): class RoleListView(generic.ObjectListView): queryset = Role.objects.annotate( prefix_count=count_related(Prefix, 'role'), + iprange_count=count_related(IPRange, 'role'), vlan_count=count_related(VLAN, 'role') ) filterset = filtersets.RoleFilterSet diff --git a/netbox/templates/ipam/role.html b/netbox/templates/ipam/role.html index 879dccdfd..49570099d 100644 --- a/netbox/templates/ipam/role.html +++ b/netbox/templates/ipam/role.html @@ -38,6 +38,30 @@ {{ prefixes_table.rows|length }} + + IP Ranges + + {% with ipranges_count=object.ip_ranges.count %} + {% if ipranges_count %} + {{ ipranges_count }} + {% else %} + — + {% endif %} + {% endwith %} + + + + VLANs + + {% with vlans_count=object.vlans.count %} + {% if vlans_count %} + {{ vlans_count }} + {% else %} + — + {% endif %} + {% endwith %} + +