Skip to content

Commit d6c8d15

Browse files
committed
Closes #11039: List parent prefixes under IP range view
1 parent e6642b5 commit d6c8d15

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

netbox/ipam/views.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,26 @@ class IPRangeListView(generic.ObjectListView):
661661
class IPRangeView(generic.ObjectView):
662662
queryset = IPRange.objects.all()
663663

664+
def get_extra_context(self, request, instance):
665+
666+
# Parent prefixes table
667+
parent_prefixes = Prefix.objects.restrict(request.user, 'view').filter(
668+
Q(prefix__net_contains_or_equals=str(instance.start_address.ip)),
669+
Q(prefix__net_contains_or_equals=str(instance.end_address.ip)),
670+
vrf=instance.vrf
671+
).prefetch_related(
672+
'site', 'role', 'tenant', 'vlan', 'role'
673+
)
674+
parent_prefixes_table = tables.PrefixTable(
675+
list(parent_prefixes),
676+
exclude=('vrf', 'utilization'),
677+
orderable=False
678+
)
679+
680+
return {
681+
'parent_prefixes_table': parent_prefixes_table,
682+
}
683+
664684

665685
@register_model_view(IPRange, 'ipaddresses', path='ip-addresses')
666686
class IPRangeIPAddressesView(generic.ObjectChildrenView):

netbox/templates/ipam/iprange.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ <h5 class="card-header">
8282
{% plugin_right_page object %}
8383
</div>
8484
</div>
85+
<div class="row">
86+
<div class="col col-md-12">
87+
{% include 'inc/panel_table.html' with table=parent_prefixes_table heading='Parent Prefixes' %}
88+
</div>
89+
</div>
8590
<div class="row">
8691
<div class="col col-md-12">
8792
{% plugin_full_width_page object %}

0 commit comments

Comments
 (0)