Allow vlans within devices site group to be assigned to interface #6761

Closed
opened 2025-12-29 19:45:08 +01:00 by adam · 3 comments
Owner

Originally created by @DanSheps on GitHub (Aug 2, 2022).

NetBox version

3.2.7

Feature type

Change to existing functionality

Proposed functionality

Change the functioning of the "available_on_device" parameter for the vlan API to additionally include the devices site_group when looking at VLANs.

Currently, available_on_device goes up "1 level" to the site when searching for vlans available on device. By allowing it to go up to the site's group you can include stretched L2 networks across multiple sites.

This would also likely require changes to clean() and save() to allow for these assignments.

Use case

Lets say you have "Switch 1" in "Site A" but only services "Site B" because of building constraints. You may have an identical VLAN in Site A already but is distinct you then have a VLAN collision within "Site A" and cannot save the VLAN due to model constraints. This would work as a vlan group, however you lose your direct site relation because of it and have to traverse the vlan groups.

Database changes

No changes required

External dependencies

No external dependencies

Originally created by @DanSheps on GitHub (Aug 2, 2022). ### NetBox version 3.2.7 ### Feature type Change to existing functionality ### Proposed functionality Change the functioning of the "available_on_device" parameter for the vlan API to additionally include the devices site_group when looking at VLANs. Currently, available_on_device goes up "1 level" to the site when searching for vlans available on device. By allowing it to go up to the site's group you can include stretched L2 networks across multiple sites. This would also likely require changes to clean() and save() to allow for these assignments. ### Use case Lets say you have "Switch 1" in "Site A" but only services "Site B" because of building constraints. You may have an identical VLAN in Site A already but is distinct you then have a VLAN collision within "Site A" and cannot save the VLAN due to model constraints. This would work as a vlan group, however you lose your direct site relation because of it and have to traverse the vlan groups. ### Database changes No changes required ### External dependencies No external dependencies
adam added the type: featurepending closurestatus: under review labels 2025-12-29 19:45:08 +01:00
adam closed this issue 2025-12-29 19:45:08 +01:00
Author
Owner

@DanSheps commented on GitHub (Aug 2, 2022):

Implementation

Change:

ff3fcb8134/netbox/ipam/querysets.py (L69-L74)

To:


        return self.filter(
            Q(group__in=VLANGroup.objects.filter(q)) |
            Q(site=device.site) |
            Q(site__group=device.site.group) |
            Q(group__scope_id__isnull=True, site__isnull=True) |  # Global group VLANs
            Q(group__isnull=True, site__isnull=True)  # Global VLANs
        )

Change:

ff3fcb8134/netbox/dcim/models/device_components.py (L761)

To:

if self.untagged_vlan and (self.untagged_vlan.site not in [self.device.site, None] or self.untagged_vlan.site.group not in [self.device.site.group, None]):
@DanSheps commented on GitHub (Aug 2, 2022): ### Implementation Change: https://github.com/netbox-community/netbox/blob/ff3fcb8134c229033453afadcc1e315c52f3fd20/netbox/ipam/querysets.py#L69-L74 To: ```python return self.filter( Q(group__in=VLANGroup.objects.filter(q)) | Q(site=device.site) | Q(site__group=device.site.group) | Q(group__scope_id__isnull=True, site__isnull=True) | # Global group VLANs Q(group__isnull=True, site__isnull=True) # Global VLANs ) ``` Change: https://github.com/netbox-community/netbox/blob/ff3fcb8134c229033453afadcc1e315c52f3fd20/netbox/dcim/models/device_components.py#L761 To: ```python if self.untagged_vlan and (self.untagged_vlan.site not in [self.device.site, None] or self.untagged_vlan.site.group not in [self.device.site.group, None]): ```
Author
Owner

@github-actions[bot] commented on GitHub (Oct 2, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Oct 2, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2022):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Nov 2, 2022): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6761