Cannot unassign a site from a vlan #4250

Closed
opened 2025-12-29 18:34:14 +01:00 by adam · 10 comments
Owner

Originally created by @candlerb on GitHub (Nov 6, 2020).

Originally assigned to: @DanSheps on GitHub.

Environment

  • Python version: 3.6.9
  • NetBox version: 2.9.8

Steps to Reproduce

  1. Create a VLAN, say ID "123" name "foo" and save. (No site assigned)
  2. Edit the VLAN. Set the site to some existing site, and save.
  3. Edit the VLAN. Set the site to "None" and save.

Expected Behavior

To be able to set the site to "None"

Observed Behavior

After selecting "None" and clicking Save, the update is rejected:

image

Originally created by @candlerb on GitHub (Nov 6, 2020). Originally assigned to: @DanSheps on GitHub. ### Environment * Python version: 3.6.9 * NetBox version: 2.9.8 ### Steps to Reproduce 1. Create a VLAN, say ID "123" name "foo" and save. (No site assigned) 2. Edit the VLAN. Set the site to some existing site, and save. 3. Edit the VLAN. Set the site to "None" and save. ### Expected Behavior To be able to set the site to "None" ### Observed Behavior After selecting "None" and clicking Save, the update is rejected: ![image](https://user-images.githubusercontent.com/44789/98389670-45779400-204c-11eb-9460-48edd19e3160.png)
adam added the type: bugstatus: accepted labels 2025-12-29 18:34:14 +01:00
adam closed this issue 2025-12-29 18:34:14 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 6, 2020):

I tried several times but haven't been able to reproduce this on v2.9.8. On step three, the VLAN saves as expected with no site assigned.

@jeremystretch commented on GitHub (Nov 6, 2020): I tried several times but haven't been able to reproduce this on v2.9.8. On step three, the VLAN saves as expected with no site assigned.
Author
Owner

@candlerb commented on GitHub (Nov 6, 2020):

Weird.

root@netbox:/opt/netbox# git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
root@netbox:/opt/netbox# git show
commit 6dcb2de28f65c4907332ede49430f64b3aff1d18 (HEAD -> master, tag: v2.9.8, origin/master)
Merge: 1bbfc6da cbd15540
Author: Jeremy Stretch <jeremy.stretch@networktocode.com>
Date:   Fri Oct 30 10:38:17 2020 -0400

    Merge pull request #5293 from netbox-community/develop

    Release v2.9.8

I have restarted Netbox - no difference.

The message "Select a valid choice" seems to be in the django source, but the packages match requirements.txt:

root@netbox:/opt/netbox# . venv/bin/activate
(venv) root@netbox:/opt/netbox# pip3 list | grep -i django
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Django (3.1)
django-cacheops (5.1)
django-cors-headers (3.4.0)
django-debug-toolbar (2.2)
django-filter (2.3.0)
django-js-asset (1.2.2)
django-mptt (0.11.0)
django-pglocks (1.0.4)
django-prometheus (2.0.0)
django-rq (2.3.2)
django-tables2 (2.3.1)
django-taggit (1.3.0)
django-timezone-field (4.0)
djangorestframework (3.11.0)
@candlerb commented on GitHub (Nov 6, 2020): Weird. ``` root@netbox:/opt/netbox# git status On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean root@netbox:/opt/netbox# git show commit 6dcb2de28f65c4907332ede49430f64b3aff1d18 (HEAD -> master, tag: v2.9.8, origin/master) Merge: 1bbfc6da cbd15540 Author: Jeremy Stretch <jeremy.stretch@networktocode.com> Date: Fri Oct 30 10:38:17 2020 -0400 Merge pull request #5293 from netbox-community/develop Release v2.9.8 ``` I have restarted Netbox - no difference. The message "Select a valid choice" seems to be in the django source, but the packages match `requirements.txt`: ``` root@netbox:/opt/netbox# . venv/bin/activate (venv) root@netbox:/opt/netbox# pip3 list | grep -i django DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. Django (3.1) django-cacheops (5.1) django-cors-headers (3.4.0) django-debug-toolbar (2.2) django-filter (2.3.0) django-js-asset (1.2.2) django-mptt (0.11.0) django-pglocks (1.0.4) django-prometheus (2.0.0) django-rq (2.3.2) django-tables2 (2.3.1) django-taggit (1.3.0) django-timezone-field (4.0) djangorestframework (3.11.0) ```
Author
Owner

@jeremystretch commented on GitHub (Nov 6, 2020):

Do you maybe have a VLAN group or site region in play? Not sure that it would matter.

@jeremystretch commented on GitHub (Nov 6, 2020): Do you maybe have a VLAN group or site region in play? Not sure that it would matter.
Author
Owner

@candlerb commented on GitHub (Nov 6, 2020):

I note that the word "None" rather than "---" appears in the dropdown: do you see the same?

image

The HTML is:

<ul class="select2-results__options" role="listbox" id="select2-id_site-results" aria-expanded="true" aria-hidden="false">
  <li class="select2-results__option select2-results__option--highlighted" role="option" aria-selected="false" data-select2-id="17">None</li>
  <li class="select2-results__option" role="option" aria-selected="false" data-select2-id="18">Main Site</li>
  <li class="select2-results__option" role="option" aria-selected="false" data-select2-id="19">Test Site</li>
</ul>

I don't know what data-select2-id values represent. These aren't the ids of the sites:

netbox=# select id, name from dcim_site;
 id |   name
----+-----------
  7 | Test Site
  1 | Main Site
(2 rows)
@candlerb commented on GitHub (Nov 6, 2020): I note that the word "None" rather than "---" appears in the dropdown: do you see the same? ![image](https://user-images.githubusercontent.com/44789/98392856-66da7f00-2050-11eb-8b0e-f8c7a20543c1.png) The HTML is: ``` <ul class="select2-results__options" role="listbox" id="select2-id_site-results" aria-expanded="true" aria-hidden="false"> <li class="select2-results__option select2-results__option--highlighted" role="option" aria-selected="false" data-select2-id="17">None</li> <li class="select2-results__option" role="option" aria-selected="false" data-select2-id="18">Main Site</li> <li class="select2-results__option" role="option" aria-selected="false" data-select2-id="19">Test Site</li> </ul> ``` I don't know what `data-select2-id` values represent. These aren't the ids of the sites: ``` netbox=# select id, name from dcim_site; id | name ----+----------- 7 | Test Site 1 | Main Site (2 rows) ```
Author
Owner

@candlerb commented on GitHub (Nov 6, 2020):

Do you maybe have a VLAN group or site region in play? Not sure that it would matter.

No vlan groups, but one of the sites ("Main Site") is in a region.

@candlerb commented on GitHub (Nov 6, 2020): > Do you maybe have a VLAN group or site region in play? Not sure that it would matter. No vlan groups, but one of the sites ("Main Site") is in a region.
Author
Owner

@candlerb commented on GitHub (Nov 6, 2020):

I've removed the site from a region.

However I've now noticed there are two different things. There's the "X" next to the site, and there's selecting site "None".

image

Clicking the "X" gives:

image

As long as I don't click None, but instead click outside of the whole drop-down, I get:

image

And now I can save successfully. It seems the "None" option in the dropdown is spurious.

@candlerb commented on GitHub (Nov 6, 2020): I've removed the site from a region. However I've now noticed there are two different things. There's the "X" next to the site, and there's selecting site "None". ![image](https://user-images.githubusercontent.com/44789/98393670-8625dc00-2051-11eb-9dc8-0eb679ba806d.png) Clicking the "X" gives: ![image](https://user-images.githubusercontent.com/44789/98393707-950c8e80-2051-11eb-805c-d49f8e753d9e.png) As long as I don't click None, but instead click outside of the whole drop-down, I get: ![image](https://user-images.githubusercontent.com/44789/98393771-ab1a4f00-2051-11eb-9529-d0f13e5fc37f.png) And now I can save successfully. It seems the "None" option in the dropdown is spurious.
Author
Owner

@jeremystretch commented on GitHub (Nov 6, 2020):

Aha, yeah that's it. I had none selected, rather than selecting None. 😄

We can probably just get rid of the explicit "None" option.

@jeremystretch commented on GitHub (Nov 6, 2020): Aha, yeah that's it. I had none selected, rather than selecting None. :smile: We can probably just get rid of the explicit "None" option.
Author
Owner

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

We have a bit of a problem in that the site field in this case is used for two things:

  1. Assigning the VLAN to a site
  2. Restricting the option returned when selecting a VLAN group

Currently, if the site field is left deselected, the group field will list all available VLAN groups. If the site is set to "None," it will return only VLAN groups which belong to that site (although VLAN creation will ultimately fail as described above).

If we simply remove the "None" option, it becomes impossible to filter VLAN groups by site. This same pattern is present elsewhere in NetBox, too.

@jeremystretch commented on GitHub (Nov 9, 2020): We have a bit of a problem in that the site field in this case is used for two things: 1. Assigning the VLAN to a site 2. Restricting the option returned when selecting a VLAN group Currently, if the site field is left deselected, the group field will list _all_ available VLAN groups. If the site is set to "None," it will return only VLAN groups which belong to that site (although VLAN creation will ultimately fail as described above). If we simply remove the "None" option, it becomes impossible to filter VLAN groups by site. This same pattern is present elsewhere in NetBox, too.
Author
Owner

@candlerb commented on GitHub (Nov 10, 2020):

Interesting. If you could make selecting the explicit "None" option work as a choice, that would be fine.

There's a secondary reported problem there which I haven't ticketed yet. It's to do with prefixes.

As I understand it: if you set a Site on a prefix, then choose a VLAN, it only offers you the VLANs linked to that site (not global VLANs). But If you select the VLAN first, then select a Site, you can choose a global VLAN and it's accepted.

@candlerb commented on GitHub (Nov 10, 2020): Interesting. If you could make selecting the explicit "None" option work as a choice, that would be fine. There's a secondary reported problem there which I haven't ticketed yet. It's to do with prefixes. As I understand it: if you set a Site on a prefix, *then* choose a VLAN, it only offers you the VLANs linked to that site (not global VLANs). But If you select the VLAN first, *then* select a Site, you can choose a global VLAN and it's accepted.
Author
Owner

@DanSheps commented on GitHub (Jan 26, 2021):

Might have a workable solution for this, currently testing and will push tomorrow hopefully.

@DanSheps commented on GitHub (Jan 26, 2021): Might have a workable solution for this, currently testing and will push tomorrow hopefully.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4250