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

Fixes #6177: Prevent VM interface from being assigned as its own parent

This commit is contained in:
jeremystretch
2021-04-16 09:18:58 -04:00
parent c24cac9a44
commit 5bd30060e7
2 changed files with 5 additions and 0 deletions

View File

@ -463,6 +463,10 @@ class VMInterface(PrimaryModel, BaseInterface):
f"({self.parent.virtual_machine})."
})
# 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."})
# Validate untagged VLAN
if self.untagged_vlan and self.untagged_vlan.site not in [self.virtual_machine.site, None]:
raise ValidationError({