Replace 'is_connected' boolean with Cable attachment

This commit is contained in:
Jeremy Stretch
2018-10-29 13:36:41 -04:00
parent 427226de8c
commit d7766b9828
5 changed files with 26 additions and 66 deletions

View File

@@ -1888,7 +1888,9 @@ class Interface(CableTermination, ComponentModel):
})
# Virtual interfaces cannot be connected
if self.form_factor in NONCONNECTABLE_IFACE_TYPES and self.is_connected:
if self.form_factor in NONCONNECTABLE_IFACE_TYPES and (
self.cable or getattr(self, 'circuit_termination', False)
):
raise ValidationError({
'form_factor': "Virtual and wireless interfaces cannot be connected to another interface or circuit. "
"Disconnect the interface or choose a suitable form factor."
@@ -1977,14 +1979,6 @@ class Interface(CableTermination, ComponentModel):
def is_lag(self):
return self.form_factor == IFACE_FF_LAG
@property
def is_connected(self):
try:
return bool(self.circuit_termination)
except ObjectDoesNotExist:
pass
return bool(self.connected_endpoint)
#
# Pass-through ports