mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Tweak tracing logic to ensure consistent behavior
This commit is contained in:
@ -108,14 +108,19 @@ class CableTermination(models.Model):
|
|||||||
# Map a front port to its corresponding rear port
|
# Map a front port to its corresponding rear port
|
||||||
if isinstance(termination, FrontPort):
|
if isinstance(termination, FrontPort):
|
||||||
position_stack.append(termination.rear_port_position)
|
position_stack.append(termination.rear_port_position)
|
||||||
return termination.rear_port
|
# Retrieve the corresponding RearPort from database to ensure we have an up-to-date instance
|
||||||
|
peer_port = RearPort.objects.get(pk=termination.rear_port.pk)
|
||||||
|
return peer_port
|
||||||
|
|
||||||
# Map a rear port/position to its corresponding front port
|
# Map a rear port/position to its corresponding front port
|
||||||
elif isinstance(termination, RearPort):
|
elif isinstance(termination, RearPort):
|
||||||
|
|
||||||
# Can't map to a FrontPort without a position
|
# Can't map to a FrontPort without a position
|
||||||
if not position_stack:
|
if not position_stack:
|
||||||
return None
|
# TODO: This behavior is broken. We need a mechanism by which to return all FrontPorts mapped
|
||||||
|
# to a given RearPort so that we can update end-to-end paths when a cable is created/deleted.
|
||||||
|
# For now, we're maintaining the current behavior of tracing only to the first FrontPort.
|
||||||
|
position_stack.append(1)
|
||||||
|
|
||||||
position = position_stack.pop()
|
position = position_stack.pop()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user