Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions netbox/dcim/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ def retrace_cable_paths(instance, **kwargs):
cablepath.retrace()


@receiver(post_save, sender=Cable)
def retrace_cable_paths_on_raw_create(sender, instance, raw=False, **kwargs):
"""
Trigger cable path retracing for a Cable instance when dependencies need to be
recalculated. Callers should fire post_save with post_raw_create=True after
all CableTerminations are in place.
"""
post_raw_create = kwargs.get('post_raw_create', False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my earlier feedback wasn't clear. I don't think we need a custom argument at all. post_save already passes created and raw booleans: It should suffice to check whether both are true.

if not post_raw_create:
return
instance._terminations_modified = True
trace_paths.send(Cable, instance=instance, created=True)


@receiver((post_delete, post_save), sender=PortMapping)
def update_passthrough_port_paths(instance, **kwargs):
"""
Expand Down
Loading