Skip to content

17414 allow single vlan in vlan group #17418

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

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion netbox/ipam/models/vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def clean(self):
if self.vid_ranges and check_ranges_overlap(self.vid_ranges):
raise ValidationError({'vid_ranges': _("Ranges cannot overlap.")})
for vid_range in self.vid_ranges:
if vid_range.lower >= vid_range.upper:
if vid_range.lower > vid_range.upper:
raise ValidationError({
'vid_ranges': _(
"Maximum child VID must be greater than or equal to minimum child VID ({value})"
Expand Down
14 changes: 14 additions & 0 deletions netbox/ipam/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,17 @@ def test_vid_validation(self):

vlan = VLAN(vid=109, name='VLAN 109', group=vlangroup)
vlan.full_clean()

def test_overlapping_vlan(self):
vlangroup = VLANGroup(
name='VLAN Group 1',
slug='vlan-group-1',
vid_ranges=string_to_ranges('2-4,3-5'),
)
with self.assertRaises(ValidationError):
vlangroup.full_clean()

# make sure single vlan range works
vlangroup.vid_ranges = string_to_ranges('2-2')
vlangroup.full_clean()
vlangroup.save()