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