Skip to content

Conversation

@renatoalmeidaoliveira
Copy link
Contributor

Fixes: #18582 Bulk import prefixes with associated VLAN not working when multiple VLANs with the same vid exist.

  • PrefixImportForm already implemented a test case for VLAN Site and VLANGroup code
  • Only a CSVModelChoiceField for vlan_group was implemented

The fix consisted in implementing a CSVModelChoiceField for Site

Aditional observations:

It should be possible to setup the VLAN queryset to the same as the Prefix scope if existent, but IMO that could lead to unwanted results, like:

  • User Creates a VLAN that doesn't belong to any Site, that VLAN gonna be missing in the queryset.

@renatoalmeidaoliveira renatoalmeidaoliveira requested review from a team and jeremystretch and removed request for a team March 8, 2025 00:50
to_field_name='name',
help_text=_("VLAN's group (if any)")
)
site = CSVModelChoiceField(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should rename this to vlan_site to make it clear that the field is considered for only the VLAN to which the prefix is being assigned, and not the prefix itself.

Suggested change
site = CSVModelChoiceField(
vlan_site = CSVModelChoiceField(

fields = (
'prefix', 'vrf', 'tenant', 'vlan_group', 'vlan', 'status', 'role', 'scope_type', 'scope_id', 'is_pool',
'mark_utilized', 'description', 'comments', 'tags',
'prefix', 'vrf', 'tenant', 'vlan_group', 'site', 'vlan', 'status', 'role', 'scope_type', 'scope_id',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'prefix', 'vrf', 'tenant', 'vlan_group', 'site', 'vlan', 'status', 'role', 'scope_type', 'scope_id',
'prefix', 'vrf', 'tenant', 'vlan_group', 'vlan_site', 'vlan', 'status', 'role', 'scope_type', 'scope_id',

@jeremystretch jeremystretch merged commit 5d81f91 into netbox-community:main Mar 11, 2025
3 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2025
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.

Bulk import prefixes with associated VLAN not working when multiple VLANs with the same vid exist.

2 participants