1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

#8272: Cleanup & add filter for bridge_id

This commit is contained in:
jeremystretch
2023-03-20 11:40:45 -04:00
parent 3b9fda0169
commit 0455654f71
4 changed files with 46 additions and 8 deletions

View File

@@ -377,6 +377,8 @@ class InterfaceTemplate(ModularComponentTemplateModel):
super().clean()
if self.bridge:
if self.pk and self.bridge_id == self.pk:
raise ValidationError({'bridge': "An interface cannot be bridged to itself."})
if self.device_type and self.device_type != self.bridge.device_type:
raise ValidationError({
'bridge': f"Bridge interface ({self.bridge}) must belong to the same device type"