Skip to content

Commit

Permalink
Fixes #14482 - Fix validation error when primary IP is moved (#14514)
Browse files Browse the repository at this point in the history
* Fix validation when primary IP is moved.

* Fix views test

* Work on excluding assigned_objects

* Modify clean() on model and form to properly catch error

* Fix test failure

* Fix test to check for PK

* Remove model_form check
  • Loading branch information
DanSheps authored Dec 28, 2023
1 parent fedcbaf commit 45c646d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions netbox/ipam/models/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,11 +864,9 @@ def clean(self):
is_primary = True

if is_primary and (parent != original_parent):
raise ValidationError({
'assigned_object': _(
"Cannot reassign IP address while it is designated as the primary IP for the parent object"
)
})
raise ValidationError(
_("Cannot reassign IP address while it is designated as the primary IP for the parent object")
)

# Validate IP status selection
if self.status == IPAddressStatusChoices.STATUS_SLAAC and self.family != 6:
Expand Down

0 comments on commit 45c646d

Please sign in to comment.