Fixes #468: Added validation to prevent a connected interface from having its form factor set to 'virtual'

This commit is contained in:
Jeremy Stretch 2016-08-15 15:52:06 -04:00
parent 8faa16c831
commit 13136d0ccb

View File

@ -1032,6 +1032,13 @@ class Interface(models.Model):
def __unicode__(self):
return self.name
def clean(self):
if self.form_factor == IFACE_FF_VIRTUAL and self.is_connected:
raise ValidationError({'form_factor': "Virtual interfaces cannot be connected to another interface or "
"circuit. Disconnect the interface or choose a physical form "
"factor."})
@property
def is_physical(self):
return self.form_factor != IFACE_FF_VIRTUAL