mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 02:48:38 -06:00
Handle case where trace ends at cable termination (#4812 example 2)
This commit is contained in:
parent
bf1c0b7b1c
commit
15c39340c4
@ -36,6 +36,8 @@ def update_connected_endpoints(instance, **kwargs):
|
|||||||
"""
|
"""
|
||||||
When a Cable is saved, check for and update its two connected endpoints
|
When a Cable is saved, check for and update its two connected endpoints
|
||||||
"""
|
"""
|
||||||
|
from circuits.models import CircuitTermination
|
||||||
|
|
||||||
logger = logging.getLogger('netbox.dcim.cable')
|
logger = logging.getLogger('netbox.dcim.cable')
|
||||||
|
|
||||||
# Cache the Cable on its two termination points
|
# Cache the Cable on its two termination points
|
||||||
@ -60,7 +62,13 @@ def update_connected_endpoints(instance, **kwargs):
|
|||||||
break
|
break
|
||||||
|
|
||||||
endpoint_a = path[0][0]
|
endpoint_a = path[0][0]
|
||||||
endpoint_b = path[-1][2] if not split_ends and not position_stack else None
|
if not split_ends and not position_stack:
|
||||||
|
endpoint_b = path[-1][2]
|
||||||
|
if endpoint_b is None and len(path) >= 2 and isinstance(path[-2][2], CircuitTermination):
|
||||||
|
# Simulate the previous behaviour and use the circuit termination as connected endpoint
|
||||||
|
endpoint_b = path[-2][2]
|
||||||
|
else:
|
||||||
|
endpoint_b = None
|
||||||
|
|
||||||
# Patch panel ports are not connected endpoints, all other cable terminations are
|
# Patch panel ports are not connected endpoints, all other cable terminations are
|
||||||
if isinstance(endpoint_a, CableTermination) and not isinstance(endpoint_a, (FrontPort, RearPort)) and \
|
if isinstance(endpoint_a, CableTermination) and not isinstance(endpoint_a, (FrontPort, RearPort)) and \
|
||||||
|
Loading…
Reference in New Issue
Block a user