Просмотр исходного кода

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

jeremystretch 4 лет назад
Родитель
Сommit
cdc73d4f56

+ 1 - 0
docs/release-notes/version-3.1.md

@@ -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
 
 

+ 18 - 18
netbox/templates/dcim/device.html

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

+ 2 - 2
netbox/templates/ipam/ipaddress.html

@@ -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 %}

+ 18 - 18
netbox/templates/virtualization/virtualmachine.html

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