From d474fa6bcf8bbf9a956f83d730fee3c9746f9495 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Tue, 24 Sep 2019 10:39:38 -0500 Subject: [PATCH] Changed to use NONCONNECTABLE_IFACE_TYPES --- netbox/dcim/models.py | 50 +++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index da1f11d21..8173e2808 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -2861,40 +2861,24 @@ class Cable(ChangeLoggedModel): # Virtual interfaces cannot be connected endpoint_a, endpoint_b, _ = self.get_path_endpoints() if ( - ( - isinstance(endpoint_a, Interface) and - endpoint_a.type == IFACE_TYPE_VIRTUAL - ) or - ( - isinstance(endpoint_b, Interface) and - endpoint_b.type == IFACE_TYPE_VIRTUAL - ) or - ( - isinstance(self.termination_a, Interface) and - self.termination_a.type == IFACE_TYPE_VIRTUAL - ) or - ( - isinstance(self.termination_b, Interface) and - self.termination_b.type == IFACE_TYPE_VIRTUAL - ) or - ( - isinstance(endpoint_b, Interface) and - endpoint_b.type in WIRELESS_IFACE_TYPES - ) or - ( - isinstance(endpoint_b, Interface) and - endpoint_b.type in WIRELESS_IFACE_TYPES - ) or - ( - isinstance(self.termination_a, Interface) and - self.termination_a.type in WIRELESS_IFACE_TYPES - ) or - ( - isinstance(self.termination_b, Interface) and - self.termination_b.type in WIRELESS_IFACE_TYPES - ) + ( + isinstance(endpoint_a, Interface) and + endpoint_a.type in NONCONNECTABLE_IFACE_TYPES + ) or + ( + isinstance(endpoint_b, Interface) and + endpoint_b.type in NONCONNECTABLE_IFACE_TYPES + ) or + ( + isinstance(self.termination_a, Interface) and + self.termination_a.type in NONCONNECTABLE_IFACE_TYPES + ) or + ( + isinstance(self.termination_b, Interface) and + self.termination_b.type in NONCONNECTABLE_IFACE_TYPES + ) ): - raise ValidationError("Cannot connect to a virtual interface") + raise ValidationError("Cannot connect to a virtual or wireless interface") # Validate length and length_unit if self.length is not None and self.length_unit is None: