Add site specific vlans to bulk editing of interfaces #3596

Closed
opened 2025-12-29 18:30:03 +01:00 by adam · 7 comments
Owner

Originally created by @nathbooth on GitHub (Apr 22, 2020).

Originally assigned to: @DanSheps on GitHub.

Environment

  • Python version: 3.7
  • NetBox version: 2.7.11

Attempt to bulk edit interfaces and add vlans;

  • Device is within a tenant
  • VLANs are linked to the same tenant
  • Navigate to Devices>Interfaces and bulk edit interfaces
  • Set mode to access or trunk
  • VLAN lookup returns 'no results found' for tagged and untagged vlans

If i edit the interfaces in the same way but select the interfaces from the device page under /dcim/devices it works correctly and shows the vlans.

Steps to Reproduce

  1. Create a tenant
  2. Create device with interfaces and vlans within that tenant
  3. Navigate to Devices>Interfaces
  4. Bulk edit device interfaces
  5. Set mode to access or trunk
  6. Observe no results found for vlans.
  7. Create new vlan without a tenant attached
  8. Repeat step 3-5
  9. Global VLAN create in step 7 is available for interface even though the device is within a tenant.

Expected Behavior

VLAN are shown for the tenant

Observed Behavior

No results are found and global vlans are shown when only tenant ones should be

Originally created by @nathbooth on GitHub (Apr 22, 2020). Originally assigned to: @DanSheps on GitHub. ### Environment * Python version: 3.7 * NetBox version: 2.7.11 Attempt to bulk edit interfaces and add vlans; - Device is within a tenant - VLANs are linked to the same tenant - Navigate to Devices>Interfaces and bulk edit interfaces - Set mode to access or trunk - VLAN lookup returns 'no results found' for tagged and untagged vlans If i edit the interfaces in the same way but select the interfaces from the device page under /dcim/devices it works correctly and shows the vlans. ### Steps to Reproduce 1. Create a tenant 2. Create device with interfaces and vlans within that tenant 3. Navigate to Devices>Interfaces 4. Bulk edit device interfaces 5. Set mode to access or trunk 6. Observe no results found for vlans. 7. Create new vlan without a tenant attached 8. Repeat step 3-5 9. Global VLAN create in step 7 is available for interface even though the device is within a tenant. ### Expected Behavior VLAN are shown for the tenant ### Observed Behavior No results are found and global vlans are shown when only tenant ones should be
adam added the type: bugstatus: accepted labels 2025-12-29 18:30:03 +01:00
adam closed this issue 2025-12-29 18:30:03 +01:00
Author
Owner

@DanSheps commented on GitHub (Apr 22, 2020):

I am not able to recreate this on https://master.netbox.dansheps.com/

Could you please test on there and then revise your steps. You need to include:

Device:

  • Site used
  • Rack, if any

Interface:

  • Type

VLAN:

  • Status
  • Site, if any
  • Group, if any

For both test cases.

@DanSheps commented on GitHub (Apr 22, 2020): I am not able to recreate this on https://master.netbox.dansheps.com/ Could you please test on there and then revise your steps. You need to include: Device: - Site used - Rack, if any Interface: - Type VLAN: - Status - Site, if any - Group, if any For both test cases.
Author
Owner

@nathbooth commented on GitHub (Apr 23, 2020):

Well you are running 2.8.0 on there, could it be that it's the same issue as this? #4474

@nathbooth commented on GitHub (Apr 23, 2020): Well you are running 2.8.0 on there, could it be that it's the same issue as this? [#4474](https://github.com/netbox-community/netbox/issues/4474)
Author
Owner

@DanSheps commented on GitHub (Apr 23, 2020):

Possible but unlikely as it wouldn't work on your second case. You can attempt to upgrade to 2.8 and see if it still persists.

@DanSheps commented on GitHub (Apr 23, 2020): Possible but unlikely as it wouldn't work on your second case. You can attempt to upgrade to 2.8 and see if it still persists.
Author
Owner

@nathbooth commented on GitHub (Apr 27, 2020):

Have upgraded to 2.8.1 and issue still persists.
The issue from what i can see is as part of the bulk edit of interfaces the lookup references site=null
GET /api/ipam/vlans/?q=&limit=50&offset=0&brief=&site_id=null
I have managed to replicate this on your test instance now.
If you try and bulk edit interfaces on device NB-TEST-SWITCH you are only able to assign vlan 100 and 101 which are not assigned to a site.
Edit from dcim/interfaces
image
Edit from devices page (appears to add site_id=null and site_id-
image

@nathbooth commented on GitHub (Apr 27, 2020): Have upgraded to 2.8.1 and issue still persists. The issue from what i can see is as part of the bulk edit of interfaces the lookup references site=null GET /api/ipam/vlans/?q=&limit=50&offset=0&brief=&site_id=null I have managed to replicate this on your test instance now. If you try and bulk edit interfaces on device NB-TEST-SWITCH you are only able to assign vlan 100 and 101 which are not assigned to a site. Edit from dcim/interfaces ![image](https://user-images.githubusercontent.com/1272614/80348121-37f37d00-8865-11ea-9f45-f7f61321e933.png) Edit from devices page (appears to add site_id=null and site_id-<id> ![image](https://user-images.githubusercontent.com/1272614/80348065-2611da00-8865-11ea-8596-e0df001bb762.png)
Author
Owner

@DanSheps commented on GitHub (Apr 27, 2020):

Alright, so it isn't that there are no sites showing, it is that there are only global sites showing. Which right now is to be expected as bulk edit has no concept of being in a site (mainly because you can bulk edit across many devices).

We can try changing this, but we would have to find a good balance. Do we only show site vlans when bulk editing devices in the same site? Do we allow bulk editing of any site a device is currently in and silently ignore invalid site vlan assignments? Do we throw an error? Do we attempt to map if the same VID's exist?

A lot of options and each might be perfectly viable.

@DanSheps commented on GitHub (Apr 27, 2020): Alright, so it isn't that there are no sites showing, it is that there are only global sites showing. Which right now is to be expected as bulk edit has no concept of being in a site (mainly because you can bulk edit across many devices). We can try changing this, but we would have to find a good balance. Do we only show site vlans when bulk editing devices in the same site? Do we allow bulk editing of any site a device is currently in and silently ignore invalid site vlan assignments? Do we throw an error? Do we attempt to map if the same VID's exist? A lot of options and each might be perfectly viable.
Author
Owner

@jeremystretch commented on GitHub (Sep 9, 2020):

@DanSheps any progress on this?

@jeremystretch commented on GitHub (Sep 9, 2020): @DanSheps any progress on this?
Author
Owner

@DanSheps commented on GitHub (Sep 29, 2020):

I have gotten this working and chosen the following approach:

If the site matches for all interfaces, the site-specific interfaces will display. If the site does not match, only global vlans will display. I think this is a nice balanced approach which does not require a lot of further coding to be workable (existing validation logic is still valid).

What we get is this:

Same Device: Shows site vlans
Different Device, Same Site: Shows site vlans
Different Device, Different Site: Only Show Global VLANs

@DanSheps commented on GitHub (Sep 29, 2020): I have gotten this working and chosen the following approach: If the site matches for all interfaces, the site-specific interfaces will display. If the site does not match, only global vlans will display. I think this is a nice balanced approach which does not require a lot of further coding to be workable (existing validation logic is still valid). What we get is this: Same Device: Shows site vlans Different Device, Same Site: Shows site vlans Different Device, Different Site: Only Show Global VLANs
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3596