|
|
@@ -93,9 +93,11 @@ class CableTermination(models.Model):
|
|
|
|
|
|
def trace(self):
|
|
|
"""
|
|
|
- Return two items: the traceable portion of a cable path, and the termination points where it splits (if any).
|
|
|
- This occurs when the trace is initiated from a midpoint along a path which traverses a RearPort. In cases where
|
|
|
- the originating endpoint is unknown, it is not possible to know which corresponding FrontPort to follow.
|
|
|
+ Return three items: the traceable portion of a cable path, the termination points where it splits (if any), and
|
|
|
+ the remaining positions on the position stack (if any). Splits occur when the trace is initiated from a midpoint
|
|
|
+ along a path which traverses a RearPort. In cases where the originating endpoint is unknown, it is not possible
|
|
|
+ to know which corresponding FrontPort to follow. Remaining positions occur when tracing a path that traverses
|
|
|
+ a FrontPort without traversing a RearPort again.
|
|
|
|
|
|
The path is a list representing a complete cable path, with each individual segment represented as a
|
|
|
three-tuple:
|
|
|
@@ -171,12 +173,12 @@ class CableTermination(models.Model):
|
|
|
if not endpoint.cable:
|
|
|
path.append((endpoint, None, None))
|
|
|
logger.debug("No cable connected")
|
|
|
- return path, None
|
|
|
+ return path, None, position_stack
|
|
|
|
|
|
# Check for loops
|
|
|
if endpoint.cable in [segment[1] for segment in path]:
|
|
|
logger.debug("Loop detected!")
|
|
|
- return path, None
|
|
|
+ return path, None, position_stack
|
|
|
|
|
|
# Record the current segment in the path
|
|
|
far_end = endpoint.get_cable_peer()
|
|
|
@@ -189,10 +191,10 @@ class CableTermination(models.Model):
|
|
|
try:
|
|
|
endpoint = get_peer_port(far_end)
|
|
|
except CableTraceSplit as e:
|
|
|
- return path, e.termination.frontports.all()
|
|
|
+ return path, e.termination.frontports.all(), position_stack
|
|
|
|
|
|
if endpoint is None:
|
|
|
- return path, None
|
|
|
+ return path, None, position_stack
|
|
|
|
|
|
def get_cable_peer(self):
|
|
|
if self.cable is None:
|
|
|
@@ -209,7 +211,7 @@ class CableTermination(models.Model):
|
|
|
endpoints = []
|
|
|
|
|
|
# Get the far end of the last path segment
|
|
|
- path, split_ends = self.trace()
|
|
|
+ path, split_ends, position_stack = self.trace()
|
|
|
endpoint = path[-1][2]
|
|
|
if split_ends is not None:
|
|
|
for termination in split_ends:
|