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

Permit the assignment of virtual interfaces as parents

This commit is contained in:
jeremystretch
2021-04-05 14:48:11 -04:00
parent 3cfab25f8a
commit 19cb575b90
3 changed files with 9 additions and 15 deletions

View File

@ -623,14 +623,14 @@ class Interface(ComponentModel, BaseInterface, CableTermination, PathEndpoint):
f"is not part of virtual chassis {self.device.virtual_chassis}."
})
# An interface cannot be its own parent
if self.pk and self.parent_id == self.pk:
raise ValidationError({'parent': "An interface cannot be its own parent."})
# A physical interface cannot have a parent interface
if self.type != InterfaceTypeChoices.TYPE_VIRTUAL and self.parent is not None:
raise ValidationError({'parent': "Only virtual interfaces may be assigned to a parent interface."})
# A virtual interface cannot be a parent interface
if self.parent is not None and self.parent.type == InterfaceTypeChoices.TYPE_VIRTUAL:
raise ValidationError({'parent': "Virtual interfaces may not be parents of other interfaces."})
# An interface's LAG must belong to the same device or virtual chassis
if self.lag and self.lag.device != self.device:
if self.device.virtual_chassis is None: