From 766e9ff31b1e2e79507d24da9ac557d24f0bf02b Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 25 Oct 2022 15:23:09 -0700 Subject: [PATCH] 10719 fix regression --- netbox/ipam/views.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index a4ccd25fe..1cbc6d56f 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -932,18 +932,19 @@ class FHRPGroupEditView(generic.ObjectEditView): return return_url def save_related_data(self, request, form, obj): - ipaddress = IPAddress( - vrf=form.cleaned_data['ip_vrf'], - address=form.cleaned_data['ip_address'], - status=form.cleaned_data['ip_status'], - role=FHRP_PROTOCOL_ROLE_MAPPINGS.get(form.cleaned_data['protocol'], IPAddressRoleChoices.ROLE_VIP), - assigned_object=obj - ) - ipaddress.save() + if form.cleaned_data.get('ip_address'): + ipaddress = IPAddress( + vrf=form.cleaned_data['ip_vrf'], + address=form.cleaned_data['ip_address'], + status=form.cleaned_data['ip_status'], + role=FHRP_PROTOCOL_ROLE_MAPPINGS.get(form.cleaned_data['protocol'], IPAddressRoleChoices.ROLE_VIP), + assigned_object=obj + ) + ipaddress.save() - # Check that the new IPAddress conforms with any assigned object-level permissions - if not IPAddress.objects.restrict(request.user, 'add').filter(pk=ipaddress.pk).first(): - raise PermissionsViolation() + # Check that the new IPAddress conforms with any assigned object-level permissions + if not IPAddress.objects.restrict(request.user, 'add').filter(pk=ipaddress.pk).first(): + raise PermissionsViolation() class FHRPGroupDeleteView(generic.ObjectDeleteView):