mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixed IPAddress 'parent prefixes' display; added warning for duplicate IPs
This commit is contained in:
parent
1ea8f04c23
commit
ab880e1053
@ -395,16 +395,24 @@ def ipaddress(request, pk):
|
|||||||
|
|
||||||
ipaddress = get_object_or_404(IPAddress.objects.select_related('interface__device'), pk=pk)
|
ipaddress = get_object_or_404(IPAddress.objects.select_related('interface__device'), pk=pk)
|
||||||
|
|
||||||
|
# Parent prefixes table
|
||||||
parent_prefixes = Prefix.objects.filter(vrf=ipaddress.vrf, prefix__net_contains=str(ipaddress.address.ip))
|
parent_prefixes = Prefix.objects.filter(vrf=ipaddress.vrf, prefix__net_contains=str(ipaddress.address.ip))
|
||||||
related_ips = IPAddress.objects.select_related('interface__device').exclude(pk=ipaddress.pk)\
|
parent_prefixes_table = tables.PrefixBriefTable(parent_prefixes)
|
||||||
.filter(vrf=ipaddress.vrf, address__net_contained_or_equal=str(ipaddress.address))
|
|
||||||
|
|
||||||
|
# Duplicate IPs table
|
||||||
|
duplicate_ips = IPAddress.objects.filter(vrf=ipaddress.vrf, address=str(ipaddress.address))\
|
||||||
|
.exclude(pk=ipaddress.pk).select_related('interface__device', 'nat_inside')
|
||||||
|
duplicate_ips_table = tables.IPAddressBriefTable(duplicate_ips)
|
||||||
|
|
||||||
|
# Related IP table
|
||||||
|
related_ips = IPAddress.objects.select_related('interface__device').exclude(address=str(ipaddress.address))\
|
||||||
|
.filter(vrf=ipaddress.vrf, address__net_contained_or_equal=str(ipaddress.address))
|
||||||
related_ips_table = tables.IPAddressBriefTable(related_ips)
|
related_ips_table = tables.IPAddressBriefTable(related_ips)
|
||||||
RequestConfig(request, paginate={'klass': EnhancedPaginator}).configure(related_ips_table)
|
|
||||||
|
|
||||||
return render(request, 'ipam/ipaddress.html', {
|
return render(request, 'ipam/ipaddress.html', {
|
||||||
'ipaddress': ipaddress,
|
'ipaddress': ipaddress,
|
||||||
'parent_prefixes': parent_prefixes,
|
'parent_prefixes_table': parent_prefixes_table,
|
||||||
|
'duplicate_ips_table': duplicate_ips_table,
|
||||||
'related_ips_table': related_ips_table,
|
'related_ips_table': related_ips_table,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -119,31 +119,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="panel panel-default">
|
{% with heading='Parent Prefixes' %}
|
||||||
<div class="panel-heading">
|
{% render_table parent_prefixes_table 'panel_table.html' %}
|
||||||
<strong>Parent Prefixes</strong>
|
{% endwith %}
|
||||||
</div>
|
{% if duplicate_ips_table.rows %}
|
||||||
{% if parent_prefixes %}
|
{% with heading='Duplicate IP Addresses' panel_class='danger' %}
|
||||||
<table class="table table-hover panel-body">
|
{% render_table duplicate_ips_table 'panel_table.html' %}
|
||||||
{% for p in parent_prefixes %}
|
{% endwith %}
|
||||||
<tr>
|
{% endif %}
|
||||||
<td>
|
|
||||||
<a href="{% url 'ipam:prefix' pk=p.pk %}">{{ p }}</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% if p.site %}
|
|
||||||
<a href="{% url 'dcim:site' slug=p.site.slug %}">{{ p.site }}</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>{{ p.status }}</td>
|
|
||||||
<td>{{ p.role }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
{% else %}
|
|
||||||
<div class="panel-body text-muted">None</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% with heading='Related IP Addresses' %}
|
{% with heading='Related IP Addresses' %}
|
||||||
{% render_table related_ips_table 'panel_table.html' %}
|
{% render_table related_ips_table 'panel_table.html' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
Loading…
Reference in New Issue
Block a user