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

Closes #12622: Fix assigning VLAN without site to Prefix #12784

Conversation

dhenschen
Copy link
Contributor

Summary

This Pull Request enables users to be to select VLANs without a site assignment during creation and bulk import of Prefixes.

This Pull Request addresses issues #12622 and #12619.

Background

Previously, only VLANs assigned to the same site as the prefix were available for selection. However, as it is possible to create VLANs without a site assignment, a subset of selectable VLANs was excluded from the VLAN filter dropdown. Additionally, the import logic did not allow the assignment of a VLAN without a site when a site was specified for the prefix.

Changes

This Pull Request introduces a selector dialog to facilitate filtering and searching for VLANs during assignment. Furthermore, the prefix import code is enhanced to include VLANs without a site assignment in the filtering logic.

Benefits

This change enhances the usability of NetBox by allowing users to assign VLANs with a null site to Prefixes through the UI. Without this modification, Prefixes could only be assigned VLANs from the same site when a site was selected for a Prefix.

Creation Test

  1. Import the demo data into NetBox
  2. Login into NetBox
  3. Import the following VLAN from with the YAML format under IPAM > VLANS > VLANs > Import
vid: 1000
name: management
status: active
  1. Create a new Prefix from IPAM > PREFIXES > Prefixes > Add.
  2. Set the Prefix field to 10.1.0.0/24
  3. Set the Site field to DM-Akron
  4. Look for the new management VLAN in the selector dialog. The user can search for a site set to None to easily find the new managment VLAN without a site.

image

  1. Click Create and Verify the new prefix is successfully created

Import Test

Steps for reproducing importing a new Prefix:

  1. Import the demo data into NetBox
  2. Login to NetBox
  3. Import the following VLAN from with the YAML format under IPAM > VLANS > VLANs > Import
vid: 1000
name: management
status: active
  1. Import a new Prefix from IPAM > PREFIXES > Prefixes > Import with the following YAML
prefix: 10.1.1.0/24
status: active
site: DM-Akron
vlan: 1000
  1. With the changes from this Pull Request, the import successfully assigns a VLAN without a site to a Prefix with a site.

Import Query Tests

I manually tested importing different variations of prefixes to verify the new query in PrefixImportForm. The query results were collected by temporarily adding a print statement to PrefixImportForm.__init__

Import Test 1

prefix: 10.1.1.0/24
status: active
site: DM-Akron
vlan: 1002
vlan_group: JBB-Global

This resulted in the following query:

(AND: (OR: ('site__name', 'DM-Akron'), ('site__name__isnull', True)), ('group__name', 'JBB-Global'))

Import Test 2

prefix: 10.1.1.0/24
status: active
site: DM-Akron
vlan: 1000

This resulted in the following query:

(OR: ('site__name', 'DM-Akron'), ('site__name__isnull', True))

Import Test 3

prefix: 10.1.1.0/24
status: active
vlan: 1000

This resulted in the following query:

(AND: )

Import Test 4

prefix: 10.1.1.0/24
status: active
vlan: 1002
vlan_group: JBB-Global

This resulted in the following query:

(AND: ('group__name', 'JBB-Global'))

@jeremystretch
Copy link
Member

LGTM! Thanks for being so thorough @dhenschen!

@jeremystretch jeremystretch merged commit 0e873a0 into netbox-community:develop Jun 14, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants