From e7cf87be97a6ce9e34e58fbe75a5609a0002b00f Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 24 Aug 2020 10:39:41 -0400 Subject: [PATCH] Fixes #5035: Fix exception when modifying an IP address assigned to a VM --- docs/release-notes/version-2.9.md | 1 + netbox/ipam/models.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-2.9.md b/docs/release-notes/version-2.9.md index d521cb13c..7f085505a 100644 --- a/docs/release-notes/version-2.9.md +++ b/docs/release-notes/version-2.9.md @@ -4,6 +4,7 @@ ### Bug Fixes +* [#5035](https://github.com/netbox-community/netbox/issues/5035) - Fix exception when modifying an IP address assigned to a VM * [#5038](https://github.com/netbox-community/netbox/issues/5038) - Fix validation of primary IPs assigned to virtual machines --- diff --git a/netbox/ipam/models.py b/netbox/ipam/models.py index 58dd96089..cf9ecbf89 100644 --- a/netbox/ipam/models.py +++ b/netbox/ipam/models.py @@ -745,7 +745,7 @@ class IPAddress(ChangeLoggedModel, CustomFieldModel): 'vminterface': f"IP address is primary for virtual machine {vm} but not assigned to an " f"interface" }) - elif self.interface.virtual_machine != vm: + elif self.assigned_object.virtual_machine != vm: raise ValidationError({ 'vminterface': f"IP address is primary for virtual machine {vm} but assigned to " f"{self.assigned_object.virtual_machine} ({self.assigned_object})"