mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixed IPAddress 'parent prefixes' display; added warning for duplicate IPs
This commit is contained in:
@@ -395,16 +395,24 @@ def ipaddress(request, 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))
|
||||
related_ips = IPAddress.objects.select_related('interface__device').exclude(pk=ipaddress.pk)\
|
||||
.filter(vrf=ipaddress.vrf, address__net_contained_or_equal=str(ipaddress.address))
|
||||
parent_prefixes_table = tables.PrefixBriefTable(parent_prefixes)
|
||||
|
||||
# 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)
|
||||
RequestConfig(request, paginate={'klass': EnhancedPaginator}).configure(related_ips_table)
|
||||
|
||||
return render(request, 'ipam/ipaddress.html', {
|
||||
'ipaddress': ipaddress,
|
||||
'parent_prefixes': parent_prefixes,
|
||||
'parent_prefixes_table': parent_prefixes_table,
|
||||
'duplicate_ips_table': duplicate_ips_table,
|
||||
'related_ips_table': related_ips_table,
|
||||
})
|
||||
|
||||
|
@@ -119,31 +119,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Parent Prefixes</strong>
|
||||
</div>
|
||||
{% if parent_prefixes %}
|
||||
<table class="table table-hover panel-body">
|
||||
{% for p in parent_prefixes %}
|
||||
<tr>
|
||||
<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='Parent Prefixes' %}
|
||||
{% render_table parent_prefixes_table 'panel_table.html' %}
|
||||
{% endwith %}
|
||||
{% if duplicate_ips_table.rows %}
|
||||
{% with heading='Duplicate IP Addresses' panel_class='danger' %}
|
||||
{% render_table duplicate_ips_table 'panel_table.html' %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% with heading='Related IP Addresses' %}
|
||||
{% render_table related_ips_table 'panel_table.html' %}
|
||||
{% endwith %}
|
||||
|
Reference in New Issue
Block a user