Fixes #2127: Prevent non-conntectable interfaces from being connected

This commit is contained in:
Jeremy Stretch 2018-06-07 14:22:56 -04:00
parent 0af6df3121
commit 643b0eaf65

View File

@ -1536,6 +1536,18 @@ class InterfaceConnection(models.Model):
raise ValidationError({
'interface_b': "Cannot connect an interface to itself."
})
if self.interface_a.form_factor in NONCONNECTABLE_IFACE_TYPES:
raise ValidationError({
'interface_a': '{} is not a connectable interface type.'.format(
self.interface_a.get_form_factor_display()
)
})
if self.interface_b.form_factor in NONCONNECTABLE_IFACE_TYPES:
raise ValidationError({
'interface_b': '{} is not a connectable interface type.'.format(
self.interface_b.get_form_factor_display()
)
})
except ObjectDoesNotExist:
pass