Closes #1202: Support overlapping assignment of NAT IP addresses

This commit is contained in:
jeremystretch 2022-05-11 16:22:07 -04:00
parent e2a02de6e9
commit 01d2ede097
5 changed files with 35 additions and 5 deletions

View File

@ -2,8 +2,13 @@
## v3.3.0 (FUTURE)
### Breaking Changes
* The `nat_outside` relation on the IP address model now returns a list of zero or more related IP addresses, rather than a single instance (or None).
### Enhancements
* [#1202](https://github.com/netbox-community/netbox/issues/1202) - Support overlapping assignment of NAT IP addresses
* [#8495](https://github.com/netbox-community/netbox/issues/8495) - Enable custom field grouping
* [#8995](https://github.com/netbox-community/netbox/issues/8995) - Enable arbitrary ordering of REST API results
@ -15,3 +20,6 @@
* extras.CustomField
* Added `group_name` field
* ipam.IPAddress
* The `nat_inside` field no longer requires a unique value
* The `nat_outside` field has changed from a single IP address instance to a list of multiple IP addresses

View File

@ -360,7 +360,7 @@ class IPAddressSerializer(NetBoxModelSerializer):
)
assigned_object = serializers.SerializerMethodField(read_only=True)
nat_inside = NestedIPAddressSerializer(required=False, allow_null=True)
nat_outside = NestedIPAddressSerializer(required=False, read_only=True)
nat_outside = NestedIPAddressSerializer(many=True, read_only=True)
class Meta:
model = IPAddress
@ -369,7 +369,6 @@ class IPAddressSerializer(NetBoxModelSerializer):
'assigned_object_id', 'assigned_object', 'nat_inside', 'nat_outside', 'dns_name', 'description', 'tags',
'custom_fields', 'created', 'last_updated',
]
read_only_fields = ['family', 'nat_outside']
@swagger_serializer_method(serializer_or_field=serializers.DictField)
def get_assigned_object(self, obj):

View File

@ -0,0 +1,17 @@
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('ipam', '0057_created_datetimefield'),
]
operations = [
migrations.AlterField(
model_name='ipaddress',
name='nat_inside',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='nat_outside', to='ipam.ipaddress'),
),
]

View File

@ -813,7 +813,7 @@ class IPAddress(NetBoxModel):
ct_field='assigned_object_type',
fk_field='assigned_object_id'
)
nat_inside = models.OneToOneField(
nat_inside = models.ForeignKey(
to='self',
on_delete=models.SET_NULL,
related_name='nat_outside',

View File

@ -91,8 +91,14 @@
</td>
</tr>
<tr>
<th scope="row">NAT (outside)</th>
<td>{{ object.nat_outside|linkify|placeholder }}</td>
<th scope="row">Outside NAT IPs</th>
<td>
{% for ip in object.nat_outside.all %}
{{ ip|linkify }}<br/>
{% empty %}
{{ ''|placeholder }}
{% endfor %}
</td>
</tr>
</table>
</div>