Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set untagged/tagged VLANs for VM interfaces through API #2014

Closed
ppmathis opened this issue Apr 8, 2018 · 2 comments
Closed

Unable to set untagged/tagged VLANs for VM interfaces through API #2014

ppmathis opened this issue Apr 8, 2018 · 2 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@ppmathis
Copy link

ppmathis commented Apr 8, 2018

Issue type

[ ] Feature request
[X] Bug report
[ ] Documentation

Environment

  • Python version: 3.5.3
  • NetBox version: 2.3.2

Description

When trying to update the untagged or tagged VLANs of a virtual machine interface through the API, the request fails with an internal server error. This can be easily replicated in pynetbox, e.g.:

iface = nb.dcim.interfaces.get(<ID of Virtual Machine Interface>)
iface.untagged_vlan = <ID of valid VLAN>
# or: iface.tagged_vlans = [<VLAN ID 1>, <VLAN ID 2>, ...]
iface.save()

The reason behind this can be easily found within the source code, where the newly assigned VLANs are being compared against device.site - however in case of a virtual machine interface, the device attribute is always None, which leads to AttributeError: NoneType object has no attribute site.

@vink78
Copy link

vink78 commented Apr 12, 2018

I've the same issue with the webui.

For the REST API, I've a partial fix here vink78@619100e using virtualization/interfaces instead of dcim/interfaces (no validation check)

@jeremystretch jeremystretch added the type: bug A confirmed report of unexpected behavior in the application label Apr 12, 2018
@jeremystretch
Copy link
Member

The reason behind this can be easily found within the source code

That links to the DCIM interface serializer. VM interfaces utilize a different set of serializers. As @vink78 points out, the mode, untagged_vlan, and tagged_vlan fields are missing from the virtualization serializers.

I've the same issue with the webui.

This would need to be addressed under a separate issue.

vink78 pushed a commit to vink78/netbox that referenced this issue Apr 18, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants