Skip to content

Commit 0a11fc1

Browse files
committed
Fixes #4030: Fix exception when setting interfaces to tagged mode in bulk
1 parent ede576a commit 0a11fc1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

docs/release-notes/version-2.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* [#4025](https://github.com/netbox-community/netbox/issues/4025) - Correct display of cable status (various places)
2323
* [#4027](https://github.com/netbox-community/netbox/issues/4027) - Repair schema migration for #3569 to convert IP addresses with DHCP status
2424
* [#4028](https://github.com/netbox-community/netbox/issues/4028) - Correct URL patterns to match Unicode characters in tag slugs
25+
* [#4030](https://github.com/netbox-community/netbox/issues/4030) - Fix exception when setting interfaces to tagged mode in bulk
2526

2627
---
2728

netbox/dcim/forms.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,7 @@ def clean_enabled(self):
27482748
return self.cleaned_data['enabled']
27492749

27502750

2751-
class InterfaceBulkEditForm(InterfaceCommonForm, BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
2751+
class InterfaceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
27522752
pk = forms.ModelMultipleChoiceField(
27532753
queryset=Interface.objects.all(),
27542754
widget=forms.MultipleHiddenInput()
@@ -2829,6 +2829,18 @@ def __init__(self, *args, **kwargs):
28292829
else:
28302830
self.fields['lag'].choices = []
28312831

2832+
def clean(self):
2833+
2834+
# Untagged interfaces cannot be assigned tagged VLANs
2835+
if self.cleaned_data['mode'] == InterfaceModeChoices.MODE_ACCESS and self.cleaned_data['tagged_vlans']:
2836+
raise forms.ValidationError({
2837+
'mode': "An access interface cannot have tagged VLANs assigned."
2838+
})
2839+
2840+
# Remove all tagged VLAN assignments from "tagged all" interfaces
2841+
elif self.cleaned_data['mode'] == InterfaceModeChoices.MODE_TAGGED_ALL:
2842+
self.cleaned_data['tagged_vlans'] = []
2843+
28322844

28332845
class InterfaceBulkRenameForm(BulkRenameForm):
28342846
pk = forms.ModelMultipleChoiceField(

0 commit comments

Comments
 (0)