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
Specifying a site during the creation or import of a prefix prevents seleting a VLAN unassigned to a site #12622
Comments
The simple solution is to switch to the selectors for filtering. This might require some backend changes through as well. |
Possible Feature Request@DanSheps , I appreciate your suggestion. I elaborated on my thoughts in next two sections below. Benefits of VLAN SelectorI believe implementing a selector similar to the site selector could enhance the user experience and address another issue outlined below. Currently, when creating a prefix without specifying a site, the filter dialog displays all VLANs that match, without providing any context about the site they belong to. This lack of context can make it challenging for users to determine the VLAN they actually want to assign, especially when there are overlaps in names and vids. Below is an example of this from the demo data. By adopting a selector approach similar to the site selector, we can provide users with the necessary information and context to make informed decisions when selecting VLANs for their prefixes. Downsides of VLAN SelectorHowever, this above example could be mitigated by the user choosing a site before selecting the VLAN. Adding a selector may require some additional verification checks to make sure the VLAN selection and site selection do not contradict. I did a test and it doesn't look like there is any current checks in NetBox to ensure that the site of a VLAN matches the site of a Prefix.
This creates a prefix belonging to Current BugfixIt is possible to fix this bug by enhancing some existing query filters. I opened the following draft pull request to outline the needed changes: #12634 |
…on a prefix import
…on a prefix import
…hout site This commit also adds tests to verify the import changes implemented in this commit.
…on a prefix import
… site This commit also adds tests to verify the import changes implemented in this commit.
… a prefix import
If this issue is accepted, I would like to take ownership of it.
|
… site This commit also adds tests to verify the import changes implemented in this commit.
… a prefix import
@DanSheps, I've discovered that the changes to implement a selector are extremely simple as you stated in your previous comment. Based on the work already completed in https://github.com/netbox-community/netbox/pull/11952/files, the diff to add a selector for VLAN in the prefix creation UI (IPAM > PREFIXES > Prefixes > Add) is as follows: diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py
index cf8117bf7..a4af2ad19 100644
--- a/netbox/ipam/forms/model_forms.py
+++ b/netbox/ipam/forms/model_forms.py
@@ -211,10 +211,8 @@ class PrefixForm(TenancyForm, NetBoxModelForm):
vlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(),
required=False,
+ selector=True,
label=_('VLAN'),
- query_params={
- 'site_id': '$site',
- }
)
role = DynamicModelChoiceField(
queryset=Role.objects.all(),
I tested this locally off of the develop branch and it accomplishes exactly what I'd like to see from this reported bug. Below is a screenshot created by following Steps to Reproduce included in this issue description. @MarcHagen I think this change would also address what you reported in issue: #12619 I have the changes on saved on a local branch of my fork. I would be interested in opening a Pull Request to implement this selector. See https://github.com/dhenschen/netbox/tree/12622-fix-assigning-vlan-without-site-to-prefix |
Would you like to implement the changes? |
@DanSheps Yes, I would like to implement the changes. Thanks! |
This would also solve the issue we have just found where the removal of the vlan_groups from the prefix model makes it hard to find the correct vlan to assign a prefix to on a site with many prefixes with the same vid or name |
… site This commit also adds tests to verify the import changes implemented in this commit.
… a prefix import
@dhenschen Thank you! |
NetBox version
v3.5.1
Python version
3.10
Steps to Reproduce
Steps for reproducing creating a new Prefix:
10.1.0.0/24
DM-Akron
Steps for reproducing importing a new Prefix:
Expected Behavior
For both creation and import, I expect to be able to assign VLANs from the same site as the prefix or VLANs without a site assignment. This is the same expectation found in issue #11619.
Observed Behavior
Record 1 vlan: Object not found: 1000
This is similar to #11619, but it impacts the IPAM app instead of DCIM. I felt that the root cause and fix was different enough that it warranted a separate issue.
I'm interesting in working this issue if it is approved.
The text was updated successfully, but these errors were encountered: