Closes #8080: Link to NAT IPs for device/VM primary IPs

This commit is contained in:
jeremystretch 2021-12-15 08:28:58 -05:00
parent d1e8c06d36
commit cdc73d4f56
4 changed files with 39 additions and 38 deletions

View File

@ -5,6 +5,7 @@
### Enhancements ### Enhancements
* [#7665](https://github.com/netbox-community/netbox/issues/7665) - Add toggle to show only available child prefixes * [#7665](https://github.com/netbox-community/netbox/issues/7665) - Add toggle to show only available child prefixes
* [#8080](https://github.com/netbox-community/netbox/issues/8080) - Link to NAT IPs for device/VM primary IPs
### Bug Fixes ### Bug Fixes

View File

@ -179,31 +179,31 @@
<tr> <tr>
<th scope="row">Primary IPv4</th> <th scope="row">Primary IPv4</th>
<td> <td>
{% if object.primary_ip4 %} {% if object.primary_ip4 %}
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a> <a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a>
{% if object.primary_ip4.nat_inside %} {% if object.primary_ip4.nat_inside %}
<span>(NAT for {{ object.primary_ip4.nat_inside.address.ip }})</span> (NAT for <a href="{{ object.primary_ip4.nat_inside.get_absolute_url }})">{{ object.primary_ip4.nat_inside.address.ip }}</a>)
{% elif object.primary_ip4.nat_outside %} {% elif object.primary_ip4.nat_outside %}
<span>(NAT: {{ object.primary_ip4.nat_outside.address.ip }})</span> (NAT: <a href="{{ object.primary_ip4.nat_outside.get_absolute_url }}">{{ object.primary_ip4.nat_outside.address.ip }}</a>)
{% endif %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %} {% endif %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %}
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Primary IPv6</th> <th scope="row">Primary IPv6</th>
<td> <td>
{% if object.primary_ip6 %} {% if object.primary_ip6 %}
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a> <a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a>
{% if object.primary_ip6.nat_inside %} {% if object.primary_ip6.nat_inside %}
<span>(NAT for {{ object.primary_ip6.nat_inside.address.ip }})</span> (NAT for <a href="{{ object.primary_ip6.nat_inside.get_absolute_url }}">{{ object.primary_ip6.nat_inside.address.ip }}</a>)
{% elif object.primary_ip6.nat_outside %} {% elif object.primary_ip6.nat_outside %}
<span>(NAT: {{ object.primary_ip6.nat_outside.address.ip }})</span> (NAT: <a href="{{ object.primary_ip6.nat_outside.get_absolute_url }}">{{ object.primary_ip6.nat_outside.address.ip }}</a>)
{% endif %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %} {% endif %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %}
</td> </td>
</tr> </tr>
{% if object.cluster %} {% if object.cluster %}

View File

@ -87,7 +87,7 @@
<th scope="row">NAT (inside)</th> <th scope="row">NAT (inside)</th>
<td> <td>
{% if object.nat_inside %} {% if object.nat_inside %}
<a href="{% url 'ipam:ipaddress' pk=object.nat_inside.pk %}">{{ object.nat_inside }}</a> <a href="{{ object.nat_inside.get_absolute_url }}">{{ object.nat_inside }}</a>
{% if object.nat_inside.assigned_object %} {% if object.nat_inside.assigned_object %}
(<a href="{{ object.nat_inside.assigned_object.parent_object.get_absolute_url }}">{{ object.nat_inside.assigned_object.parent_object }}</a>) (<a href="{{ object.nat_inside.assigned_object.parent_object.get_absolute_url }}">{{ object.nat_inside.assigned_object.parent_object }}</a>)
{% endif %} {% endif %}
@ -100,7 +100,7 @@
<th scope="row">NAT (outside)</th> <th scope="row">NAT (outside)</th>
<td> <td>
{% if object.nat_outside %} {% if object.nat_outside %}
<a href="{% url 'ipam:ipaddress' pk=object.nat_outside.pk %}">{{ object.nat_outside }}</a> <a href="{{ object.nat_outside.get_absolute_url }}">{{ object.nat_outside }}</a>
{% else %} {% else %}
<span class="text-muted">None</span> <span class="text-muted">None</span>
{% endif %} {% endif %}

View File

@ -59,31 +59,31 @@
<tr> <tr>
<th scope="row">Primary IPv4</th> <th scope="row">Primary IPv4</th>
<td> <td>
{% if object.primary_ip4 %} {% if object.primary_ip4 %}
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a> <a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a>
{% if object.primary_ip4.nat_inside %} {% if object.primary_ip4.nat_inside %}
<span>(NAT for {{ object.primary_ip4.nat_inside.address.ip }})</span> (NAT for <a href="{{ object.primary_ip4.nat_inside.get_absolute_url }}">{{ object.primary_ip4.nat_inside.address.ip }}</a>)
{% elif object.primary_ip4.nat_outside %} {% elif object.primary_ip4.nat_outside %}
<span>(NAT: {{ object.primary_ip4.nat_outside.address.ip }})</span> (NAT: <a href="{{ object.primary_ip4.nat_outside.get_absolute_url }}">{{ object.primary_ip4.nat_outside.address.ip }}</a>)
{% endif %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %} {% endif %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %}
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Primary IPv6</th> <th scope="row">Primary IPv6</th>
<td> <td>
{% if object.primary_ip6 %} {% if object.primary_ip6 %}
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a> <a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a>
{% if object.primary_ip6.nat_inside %} {% if object.primary_ip6.nat_inside %}
<span>(NAT for {{ object.primary_ip6.nat_inside.address.ip }})</span> (NAT for <a href="{{ object.primary_ip6.nat_inside.get_absolute_url }}">{{ object.primary_ip6.nat_inside.address.ip }}</a>)
{% elif object.primary_ip6.nat_outside %} {% elif object.primary_ip6.nat_outside %}
<span>(NAT: {{ object.primary_ip6.nat_outside.address.ip }})</span> (NAT: <a href="{{ object.primary_ip6.nat_outside.get_absolute_url }}">{{ object.primary_ip6.nat_outside.address.ip }}</a>)
{% endif %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %} {% endif %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %}
</td> </td>
</tr> </tr>
</table> </table>