1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #5395: Fix cable tracing for rear ports with no corresponding front port

This commit is contained in:
Jeremy Stretch
2020-12-02 12:03:25 -05:00
parent f504d1aa99
commit 8461832a7b
3 changed files with 36 additions and 5 deletions

View File

@@ -411,21 +411,27 @@ class CablePath(models.Model):
position_stack.append(peer_termination.rear_port_position)
path.append(object_to_path_node(node))
# Follow a RearPort to its corresponding FrontPort
# Follow a RearPort to its corresponding FrontPort (if any)
elif isinstance(peer_termination, RearPort):
path.append(object_to_path_node(peer_termination))
# Determine the peer FrontPort's position
if peer_termination.positions == 1:
node = FrontPort.objects.get(rear_port=peer_termination, rear_port_position=1)
path.append(object_to_path_node(node))
position = 1
elif position_stack:
position = position_stack.pop()
node = FrontPort.objects.get(rear_port=peer_termination, rear_port_position=position)
path.append(object_to_path_node(node))
else:
# No position indicated: path has split, so we stop at the RearPort
is_split = True
break
try:
node = FrontPort.objects.get(rear_port=peer_termination, rear_port_position=position)
path.append(object_to_path_node(node))
except ObjectDoesNotExist:
# No corresponding FrontPort found for the RearPort
break
# Anything else marks the end of the path
else:
destination = peer_termination