From 72f4ded24ecd49ac19b196bf34b1cc1b4dd08d75 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Sun, 20 Oct 2019 00:10:05 +0200 Subject: [PATCH] When deleting a cable make sure the trace sees the cable as gone --- netbox/dcim/signals.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/signals.py b/netbox/dcim/signals.py index f83bb9d46..86d820ef2 100644 --- a/netbox/dcim/signals.py +++ b/netbox/dcim/signals.py @@ -64,10 +64,10 @@ def nullify_connected_endpoints(instance, **kwargs): instance.termination_b.save() # Update all endpoints affected by this cable - update_endpoints(endpoints) + update_endpoints(endpoints, without_cable=instance) -def update_endpoints(endpoints): +def update_endpoints(endpoints, without_cable=None): """ Update all endpoints affected by this cable """ @@ -75,6 +75,10 @@ def update_endpoints(endpoints): if not hasattr(endpoint, 'connected_endpoint'): continue + if endpoint.cable == without_cable: + # We collected the endpoints before deleting the cable, so trace with the cable removed + endpoint.cable = None + path = endpoint.trace() # The trace returns left and right, we just want a single list