Exception when modifying properties of an IP assigned to a VM #4014

Closed
opened 2025-12-29 18:32:37 +01:00 by adam · 3 comments
Owner

Originally created by @abrahamvegh on GitHub (Aug 23, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.7.3
  • NetBox version: 2.9.1

Steps to Reproduce

  1. Create new IP e.g. 198.51.100.1/24
  2. Create new VM
  3. Create interface on VM
  4. Edit IP and assign as primary to the VM interface
  5. After the IP is assigned as primary, edit the IP and change the status to any other status
  6. Exception

Expected Behavior

Modifications to the IP should be accepted.

Observed Behavior

Exception:

Traceback (most recent call last):
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
   response = get_response(request)
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response
   response = wrapped_callback(request, *callback_args, **callback_kwargs)
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 73, in view
   return self.dispatch(request, *args, **kwargs)
 File "/opt/netbox/netbox/utilities/views.py", line 392, in dispatch
   return super().dispatch(request, *args, **kwargs)
 File "/opt/netbox/netbox/utilities/views.py", line 123, in dispatch
   return super().dispatch(request, *args, **kwargs)
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 101, in dispatch
   return handler(request, *args, **kwargs)
 File "/opt/netbox/netbox/utilities/views.py", line 418, in post
   if form.is_valid():
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 177, in is_valid
   return self.is_bound and not self.errors
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 172, in errors
   self.full_clean()
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 376, in full_clean
   self._post_clean()
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/models.py", line 405, in _post_clean
   self.instance.full_clean(exclude=exclude, validate_unique=False)
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/db/models/base.py", line 1213, in full_clean
   self.clean()
 File "/opt/netbox/netbox/ipam/models.py", line 748, in clean
   elif self.interface.virtual_machine != vm:

Exception Type: AttributeError at /ipam/ip-addresses/4195/edit/
Exception Value: 'RelatedManager' object has no attribute 'virtual_machine'

This is presumably related to #4721. I bumped into it trying to update IPs relating to #4540.

Originally created by @abrahamvegh on GitHub (Aug 23, 2020). Originally assigned to: @jeremystretch on GitHub. <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.7.3 * NetBox version: 2.9.1 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. Create new IP e.g. `198.51.100.1/24` 2. Create new VM 3. Create interface on VM 4. Edit IP and assign as primary to the VM interface 5. After the IP is assigned as primary, edit the IP and change the status to any other status 6. Exception <!-- What did you expect to happen? --> ### Expected Behavior Modifications to the IP should be accepted. <!-- What happened instead? --> ### Observed Behavior Exception: ``` Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 73, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 392, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 123, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 101, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 418, in post if form.is_valid(): File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 177, in is_valid return self.is_bound and not self.errors File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 172, in errors self.full_clean() File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 376, in full_clean self._post_clean() File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/models.py", line 405, in _post_clean self.instance.full_clean(exclude=exclude, validate_unique=False) File "/opt/netbox/venv/lib/python3.7/site-packages/django/db/models/base.py", line 1213, in full_clean self.clean() File "/opt/netbox/netbox/ipam/models.py", line 748, in clean elif self.interface.virtual_machine != vm: Exception Type: AttributeError at /ipam/ip-addresses/4195/edit/ Exception Value: 'RelatedManager' object has no attribute 'virtual_machine' ``` This is presumably related to #4721. I bumped into it trying to update IPs relating to #4540.
adam added the type: bugstatus: accepted labels 2025-12-29 18:32:37 +01:00
adam closed this issue 2025-12-29 18:32:37 +01:00
Author
Owner

@abrahamvegh commented on GitHub (Aug 24, 2020):

This seems to be affecting any modification of an IP address assigned to a VM interface.

@abrahamvegh commented on GitHub (Aug 24, 2020): This seems to be affecting any modification of an IP address assigned to a VM interface.
Author
Owner

@jeremystretch commented on GitHub (Aug 24, 2020):

Please detail the exact steps someone else can take to replicate this bug, beginning with the creation of the IP address.

@jeremystretch commented on GitHub (Aug 24, 2020): Please detail the exact steps someone else can take to replicate this bug, beginning with the creation of the IP address.
Author
Owner

@abrahamvegh commented on GitHub (Aug 24, 2020):

Updated with full steps to reproduce. The hot path seems to be when an IP is marked as primary for the interface.

@abrahamvegh commented on GitHub (Aug 24, 2020): Updated with full steps to reproduce. The hot path seems to be when an IP is marked as primary for the interface.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4014