netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Allow vlans within devices site group to be assigned to interface

Open DanSheps opened this issue 2 years ago • 2 comments

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

DanSheps avatar Aug 02 '22 20:08 DanSheps

Implementation

Change:

https://github.com/netbox-community/netbox/blob/ff3fcb8134c229033453afadcc1e315c52f3fd20/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:

https://github.com/netbox-community/netbox/blob/ff3fcb8134c229033453afadcc1e315c52f3fd20/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 avatar Aug 02 '22 20:08 DanSheps

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] avatar Oct 02 '22 04:10 github-actions[bot]

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] avatar Nov 02 '22 04:11 github-actions[bot]