diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 1de53b6d2..5fc4301bb 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -661,6 +661,26 @@ class IPRangeListView(generic.ObjectListView): class IPRangeView(generic.ObjectView): queryset = IPRange.objects.all() + def get_extra_context(self, request, instance): + + # Parent prefixes table + parent_prefixes = Prefix.objects.restrict(request.user, 'view').filter( + Q(prefix__net_contains_or_equals=str(instance.start_address.ip)), + Q(prefix__net_contains_or_equals=str(instance.end_address.ip)), + vrf=instance.vrf + ).prefetch_related( + 'site', 'role', 'tenant', 'vlan', 'role' + ) + parent_prefixes_table = tables.PrefixTable( + list(parent_prefixes), + exclude=('vrf', 'utilization'), + orderable=False + ) + + return { + 'parent_prefixes_table': parent_prefixes_table, + } + @register_model_view(IPRange, 'ipaddresses', path='ip-addresses') class IPRangeIPAddressesView(generic.ObjectChildrenView): diff --git a/netbox/templates/ipam/iprange.html b/netbox/templates/ipam/iprange.html index 3e79e6690..13bfe4902 100644 --- a/netbox/templates/ipam/iprange.html +++ b/netbox/templates/ipam/iprange.html @@ -82,6 +82,11 @@ {% plugin_right_page object %} +