From c811eb069d1d83c8735890199800eb3b2945db90 Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Thu, 18 Aug 2022 16:05:29 -0500
Subject: [PATCH 1/9] netbox-community#10055 - Add loop for NAT Outside
---
netbox/templates/dcim/device.html | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html
index 8286f2c61..217362311 100644
--- a/netbox/templates/dcim/device.html
+++ b/netbox/templates/dcim/device.html
@@ -179,8 +179,8 @@
{{ object.primary_ip4.address.ip }}
{% if object.primary_ip4.nat_inside %}
(NAT for {{ object.primary_ip4.nat_inside.address.ip|linkify }})
- {% elif object.primary_ip4.nat_outside %}
- (NAT: {{ object.primary_ip4.nat_outside.address.ip|linkify }})
+ {% elif object.primary_ip4.nat_outside.count > 0 %}
+ (NAT for {% for nat in object.primary_ip4.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
{{ ''|placeholder }}
@@ -194,8 +194,8 @@
{{ object.primary_ip6.address.ip }}
{% if object.primary_ip6.nat_inside %}
(NAT for {{ object.primary_ip6.nat_inside.address.ip|linkify }})
- {% elif object.primary_ip6.nat_outside %}
- (NAT: {{ object.primary_ip6.nat_outside.address.ip|linkify }})
+ {% elif object.primary_ip6.nat_outside.count > 0 %}
+ (NAT for {% for nat in object.primary_ip6.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
{{ ''|placeholder }}
From a687aa1de6fe702d496a5d25435bd38af4340ddb Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Thu, 18 Aug 2022 16:09:36 -0500
Subject: [PATCH 2/9] netbox-community#10055 - Add loop for NAT Outside
---
netbox/templates/virtualization/virtualmachine.html | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html
index f62da6fed..3826e0cf2 100644
--- a/netbox/templates/virtualization/virtualmachine.html
+++ b/netbox/templates/virtualization/virtualmachine.html
@@ -45,8 +45,8 @@
{{ object.primary_ip4.address.ip }}
{% if object.primary_ip4.nat_inside %}
(NAT for {{ object.primary_ip4.nat_inside.address.ip }})
- {% elif object.primary_ip4.nat_outside %}
- (NAT: {{ object.primary_ip4.nat_outside.address.ip }})
+ {% elif object.primary_ip4.nat_outside.count > 0 %}
+ (NAT for {% for nat in object.primary_ip4.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
{{ ''|placeholder }}
@@ -60,8 +60,8 @@
{{ object.primary_ip6.address.ip }}
{% if object.primary_ip6.nat_inside %}
(NAT for {{ object.primary_ip6.nat_inside.address.ip }})
- {% elif object.primary_ip6.nat_outside %}
- (NAT: {{ object.primary_ip6.nat_outside.address.ip }})
+ {% elif object.primary_ip4.nat_outside.count > 0 %}
+ (NAT for {% for nat in object.primary_ip4.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
{{ ''|placeholder }}
From 3f40e15ed5612b0567e0987b43e7e0f93447df7d Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Thu, 18 Aug 2022 16:18:29 -0500
Subject: [PATCH 3/9] netbox-community#10055 - Add template for NAT Outside
Fixes 'ipam.IPAddress.None' text
---
netbox/ipam/tables/ip.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/netbox/ipam/tables/ip.py b/netbox/ipam/tables/ip.py
index 20e63fe55..493488dac 100644
--- a/netbox/ipam/tables/ip.py
+++ b/netbox/ipam/tables/ip.py
@@ -56,6 +56,12 @@ VRF_LINK = """
{% endif %}
"""
+NAT_OUTSIDE_LINK = """
+{% if record.nat_outside.count > 0 %}
+ {% for nat in record.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %}
+{% endif %}
+"""
+
#
# RIRs
@@ -360,8 +366,8 @@ class IPAddressTable(TenancyColumnsMixin, NetBoxTable):
orderable=False,
verbose_name='NAT (Inside)'
)
- nat_outside = tables.Column(
- linkify=True,
+ nat_outside = tables.TemplateColumn(
+ template_code=NAT_OUTSIDE_LINK,
orderable=False,
verbose_name='NAT (Outside)'
)
From 0bdee1d6d8a352c2142b666ef53df6d738d0115b Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Thu, 18 Aug 2022 16:22:22 -0500
Subject: [PATCH 4/9] netbox-community#10055 - Align NAT Outside with NAT
Inside
---
netbox/templates/ipam/ipaddress.html | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/netbox/templates/ipam/ipaddress.html b/netbox/templates/ipam/ipaddress.html
index 8b628c2f7..ba0f0c5e6 100644
--- a/netbox/templates/ipam/ipaddress.html
+++ b/netbox/templates/ipam/ipaddress.html
@@ -91,10 +91,13 @@
- Outside NAT IPs |
+ NAT (Outside) |
{% for ip in object.nat_outside.all %}
- {{ ip|linkify }}
+ {{ ip|linkify }}
+ {% if ip.assigned_object %}
+ ({{ ip.assigned_object.parent_object|linkify }})
+ {% endif %}
{% empty %}
{{ ''|placeholder }}
{% endfor %}
From 43ad8e80b9bfab3eda91b0a771e4247726f54209 Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Thu, 18 Aug 2022 17:12:44 -0500
Subject: [PATCH 5/9] netbox-community#10055: Added empty text
---
netbox/ipam/tables/ip.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/netbox/ipam/tables/ip.py b/netbox/ipam/tables/ip.py
index 493488dac..52b1c4393 100644
--- a/netbox/ipam/tables/ip.py
+++ b/netbox/ipam/tables/ip.py
@@ -59,6 +59,8 @@ VRF_LINK = """
NAT_OUTSIDE_LINK = """
{% if record.nat_outside.count > 0 %}
{% for nat in record.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %}
+{% else %}
+ —
{% endif %}
"""
From 71bf5f4697ebbd00d2ac87e7972961f5f6289851 Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Mon, 22 Aug 2022 15:17:35 -0500
Subject: [PATCH 6/9] Updated exists evaluation
---
netbox/templates/dcim/device.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html
index 217362311..a798a34b0 100644
--- a/netbox/templates/dcim/device.html
+++ b/netbox/templates/dcim/device.html
@@ -179,7 +179,7 @@
{{ object.primary_ip4.address.ip }}
{% if object.primary_ip4.nat_inside %}
(NAT for {{ object.primary_ip4.nat_inside.address.ip|linkify }})
- {% elif object.primary_ip4.nat_outside.count > 0 %}
+ {% elif object.primary_ip4.nat_outside.exists %}
(NAT for {% for nat in object.primary_ip4.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
@@ -194,7 +194,7 @@
{{ object.primary_ip6.address.ip }}
{% if object.primary_ip6.nat_inside %}
(NAT for {{ object.primary_ip6.nat_inside.address.ip|linkify }})
- {% elif object.primary_ip6.nat_outside.count > 0 %}
+ {% elif object.primary_ip6.nat_outside.exists %}
(NAT for {% for nat in object.primary_ip6.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
From 2bb79e1346bdae419497176619edfe8942df1231 Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Mon, 22 Aug 2022 15:18:25 -0500
Subject: [PATCH 7/9] Updated exists evaluation
---
netbox/templates/virtualization/virtualmachine.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html
index 3826e0cf2..8b69374f1 100644
--- a/netbox/templates/virtualization/virtualmachine.html
+++ b/netbox/templates/virtualization/virtualmachine.html
@@ -45,7 +45,7 @@
{{ object.primary_ip4.address.ip }}
{% if object.primary_ip4.nat_inside %}
(NAT for {{ object.primary_ip4.nat_inside.address.ip }})
- {% elif object.primary_ip4.nat_outside.count > 0 %}
+ {% elif object.primary_ip4.nat_outside.exists %}
(NAT for {% for nat in object.primary_ip4.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
@@ -60,7 +60,7 @@
{{ object.primary_ip6.address.ip }}
{% if object.primary_ip6.nat_inside %}
(NAT for {{ object.primary_ip6.nat_inside.address.ip }})
- {% elif object.primary_ip4.nat_outside.count > 0 %}
+ {% elif object.primary_ip4.nat_outside.exists %}
(NAT for {% for nat in object.primary_ip4.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
From 6179686c81c5a33fe264046214e4b9a005b94a42 Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Mon, 22 Aug 2022 15:22:53 -0500
Subject: [PATCH 8/9] Corrected IPv6 family
---
netbox/templates/virtualization/virtualmachine.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html
index 8b69374f1..5756d939a 100644
--- a/netbox/templates/virtualization/virtualmachine.html
+++ b/netbox/templates/virtualization/virtualmachine.html
@@ -60,8 +60,8 @@
{{ object.primary_ip6.address.ip }}
{% if object.primary_ip6.nat_inside %}
(NAT for {{ object.primary_ip6.nat_inside.address.ip }})
- {% elif object.primary_ip4.nat_outside.exists %}
- (NAT for {% for nat in object.primary_ip4.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
+ {% elif object.primary_ip6.nat_outside.exists %}
+ (NAT for {% for nat in object.primary_ip6.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% else %}
{{ ''|placeholder }}
From 63e8faeed931f9ed2d589c5341976fa1b4f82324 Mon Sep 17 00:00:00 2001
From: atownson <52260120+atownson@users.noreply.github.com>
Date: Mon, 22 Aug 2022 20:34:44 -0500
Subject: [PATCH 9/9] Changed nat_outside to ManyToManyColumn
---
netbox/ipam/tables/ip.py | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/netbox/ipam/tables/ip.py b/netbox/ipam/tables/ip.py
index 52b1c4393..82f4686c0 100644
--- a/netbox/ipam/tables/ip.py
+++ b/netbox/ipam/tables/ip.py
@@ -56,14 +56,6 @@ VRF_LINK = """
{% endif %}
"""
-NAT_OUTSIDE_LINK = """
-{% if record.nat_outside.count > 0 %}
- {% for nat in record.nat_outside.all %}{{ nat.address.ip }}{% if not forloop.last %}, {% endif %}{% endfor %}
-{% else %}
- —
-{% endif %}
-"""
-
#
# RIRs
@@ -368,8 +360,8 @@ class IPAddressTable(TenancyColumnsMixin, NetBoxTable):
orderable=False,
verbose_name='NAT (Inside)'
)
- nat_outside = tables.TemplateColumn(
- template_code=NAT_OUTSIDE_LINK,
+ nat_outside = tables.ManyToManyColumn(
+ linkify_item=True,
orderable=False,
verbose_name='NAT (Outside)'
)
|