mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Fixes #5360: Clear VLAN assignments when setting interface mode to none
This commit is contained in:
parent
58668a6807
commit
3dd2e4c84c
@ -13,6 +13,7 @@
|
|||||||
* [#5350](https://github.com/netbox-community/netbox/issues/5350) - Filter available racks by selected group when creating a rack reservation
|
* [#5350](https://github.com/netbox-community/netbox/issues/5350) - Filter available racks by selected group when creating a rack reservation
|
||||||
* [#5355](https://github.com/netbox-community/netbox/issues/5355) - Limit rack groups by selected site when editing a rack
|
* [#5355](https://github.com/netbox-community/netbox/issues/5355) - Limit rack groups by selected site when editing a rack
|
||||||
* [#5356](https://github.com/netbox-community/netbox/issues/5356) - Populate manufacturer field when adding a device component template
|
* [#5356](https://github.com/netbox-community/netbox/issues/5356) - Populate manufacturer field when adding a device component template
|
||||||
|
* [#5360](https://github.com/netbox-community/netbox/issues/5360) - Clear VLAN assignments when setting interface mode to none
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -589,6 +589,18 @@ class BaseInterface(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
|
# Remove untagged VLAN assignment for non-802.1Q interfaces
|
||||||
|
if not self.mode:
|
||||||
|
self.untagged_vlan = None
|
||||||
|
|
||||||
|
# Only "tagged" interfaces may have tagged VLANs assigned. ("tagged all" implies all VLANs are assigned.)
|
||||||
|
if self.pk and self.mode != InterfaceModeChoices.MODE_TAGGED:
|
||||||
|
self.tagged_vlans.clear()
|
||||||
|
|
||||||
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@extras_features('graphs', 'export_templates', 'webhooks')
|
@extras_features('graphs', 'export_templates', 'webhooks')
|
||||||
class Interface(CableTermination, ComponentModel, BaseInterface):
|
class Interface(CableTermination, ComponentModel, BaseInterface):
|
||||||
@ -724,18 +736,6 @@ class Interface(CableTermination, ComponentModel, BaseInterface):
|
|||||||
"device, or it must be global".format(self.untagged_vlan)
|
"device, or it must be global".format(self.untagged_vlan)
|
||||||
})
|
})
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
|
|
||||||
# Remove untagged VLAN assignment for non-802.1Q interfaces
|
|
||||||
if self.mode is None:
|
|
||||||
self.untagged_vlan = None
|
|
||||||
|
|
||||||
# Only "tagged" interfaces may have tagged VLANs assigned. ("tagged all" implies all VLANs are assigned.)
|
|
||||||
if self.pk and self.mode != InterfaceModeChoices.MODE_TAGGED:
|
|
||||||
self.tagged_vlans.clear()
|
|
||||||
|
|
||||||
return super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def connected_endpoint(self):
|
def connected_endpoint(self):
|
||||||
"""
|
"""
|
||||||
|
@ -464,18 +464,6 @@ class VMInterface(BaseInterface):
|
|||||||
"virtual machine, or it must be global".format(self.untagged_vlan)
|
"virtual machine, or it must be global".format(self.untagged_vlan)
|
||||||
})
|
})
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
|
|
||||||
# Remove untagged VLAN assignment for non-802.1Q interfaces
|
|
||||||
if self.mode is None:
|
|
||||||
self.untagged_vlan = None
|
|
||||||
|
|
||||||
# Only "tagged" interfaces may have tagged VLANs assigned. ("tagged all" implies all VLANs are assigned.)
|
|
||||||
if self.pk and self.mode != InterfaceModeChoices.MODE_TAGGED:
|
|
||||||
self.tagged_vlans.clear()
|
|
||||||
|
|
||||||
return super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
# Annotate the parent VirtualMachine
|
# Annotate the parent VirtualMachine
|
||||||
return ObjectChange(
|
return ObjectChange(
|
||||||
|
Loading…
Reference in New Issue
Block a user