add range to "get_next_available_vid(self):" #4807

Closed
opened 2025-12-29 19:20:50 +01:00 by adam · 1 comment
Owner

Originally created by @PieterL75 on GitHub (Apr 22, 2021).

NetBox version

v2.10.5

Feature type

Change to existing functionality

Proposed functionality

the function "get_next_available_vid(self)" returns the first available VLAN ID (1-4094) in the group.

Can this function be updated to have 2 extra (optional) parameters

def get_next_available_vid(self, startvid=1, endvid=4094) """ Return the first available VLAN ID (startvid-endvid) in the group. """ vlan_ids = VLAN.objects.filter(group=self).values_list('vid', flat=True) for i in range(startvid, endvid): if i not in vlan_ids: return i return None

Use case

I have logical vlan ranges defined, from which I need to pick the first free. This is not always the whole 1-4096 range of a group
For now, I made my own function that does the proposed functionality, but it would make sense to update the build-in one

Database changes

No response

External dependencies

No response

Originally created by @PieterL75 on GitHub (Apr 22, 2021). ### NetBox version v2.10.5 ### Feature type Change to existing functionality ### Proposed functionality the function "get_next_available_vid(self)" returns the first available VLAN ID (1-4094) in the group. Can this function be updated to have 2 extra (optional) parameters ` def get_next_available_vid(self, startvid=1, endvid=4094) """ Return the first available VLAN ID (startvid-endvid) in the group. """ vlan_ids = VLAN.objects.filter(group=self).values_list('vid', flat=True) for i in range(startvid, endvid): if i not in vlan_ids: return i return None ` ### Use case I have logical vlan ranges defined, from which I need to pick the first free. This is not always the whole 1-4096 range of a group For now, I made my own function that does the proposed functionality, but it would make sense to update the build-in one ### Database changes _No response_ ### External dependencies _No response_
adam added the type: feature label 2025-12-29 19:20:50 +01:00
adam closed this issue 2025-12-29 19:20:50 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 22, 2021):

This function isn't part of NetBox's public API. It may be modified or removed at any time without warning. If you desire the functionality it provides, you can very easily copy it into your own work and modify it as necessary.

@jeremystretch commented on GitHub (Apr 22, 2021): This function isn't part of NetBox's public API. It may be modified or removed at any time without warning. If you desire the functionality it provides, you can very easily copy it into your own work and modify it as necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4807