From 5ce955a7194deabb18e020ff7d38def2efb61301 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 20 Nov 2018 09:23:30 -0500 Subject: [PATCH] Fixed toggling of connection status for cable path endpoints --- netbox/dcim/models.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index 59f706cb5..d1df9633d 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -2608,15 +2608,18 @@ class Cable(ChangeLoggedModel): Traverse both ends of a cable path and return its connected endpoints. Note that one or both endpoints may be None. """ - a_path = self.termination_a.trace() - b_path = self.termination_b.trace() + a_path = self.termination_b.trace() + b_path = self.termination_a.trace() # Determine overall path status (connected or planned) - cables = [segment[1] for segment in a_path + b_path] - if all(cables) and all([c.status for c in cables]): - path_status = CONNECTION_STATUS_CONNECTED - else: + if self.status == CONNECTION_STATUS_PLANNED: path_status = CONNECTION_STATUS_PLANNED + else: + path_status = CONNECTION_STATUS_CONNECTED + for segment in a_path[1:] + b_path[1:]: + if segment[1] is None or segment[1].status == CONNECTION_STATUS_PLANNED: + path_status = CONNECTION_STATUS_PLANNED + break # (A path end, B path end, connected/planned) return a_path[-1][2], b_path[-1][2], path_status