diff --git a/netbox/circuits/signals.py b/netbox/circuits/signals.py index 8c8c0d2aa..70f2abb41 100644 --- a/netbox/circuits/signals.py +++ b/netbox/circuits/signals.py @@ -17,11 +17,11 @@ def update_circuit(instance, **kwargs): @receiver((post_save, post_delete), sender=CircuitTermination) -def rebuild_cablepaths(instance, raw=False, max_length=None, **kwargs): +def rebuild_cablepaths(instance, raw=False, **kwargs): """ Rebuild any CablePaths which traverse the peer CircuitTermination. """ if not raw: peer_termination = instance.get_peer_termination() if peer_termination: - rebuild_paths([peer_termination], max_length=max_length) + rebuild_paths([peer_termination]) diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index 7a95d9852..1f5f3ffee 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -205,7 +205,6 @@ class Cable(PrimaryModel): def save(self, *args, **kwargs): _created = self.pk is None - max_length = kwargs.pop('max_length', None) # Store the given length (if any) in meters for use in database ordering if self.length is not None and self.length_unit: @@ -244,7 +243,7 @@ class Cable(PrimaryModel): if not termination.pk or termination not in b_terminations: CableTermination(cable=self, cable_end='B', termination=termination).save() - trace_paths.send(Cable, instance=self, created=_created, max_length=max_length) + trace_paths.send(Cable, instance=self, created=_created) def get_status_color(self): return LinkStatusChoices.colors.get(self.status) @@ -741,11 +740,11 @@ class CablePath(models.Model): is_split=is_split ) - def retrace(self, max_length=None): + def retrace(self): """ Retrace the path from the currently-defined originating termination(s) """ - _new = self.from_origin(self.origins, max_length=max_length) + _new = self.from_origin(self.origins) if _new: self.path = _new.path self.is_complete = _new.is_complete diff --git a/netbox/dcim/signals.py b/netbox/dcim/signals.py index 4f3cb1d9d..a51872719 100644 --- a/netbox/dcim/signals.py +++ b/netbox/dcim/signals.py @@ -72,7 +72,7 @@ def clear_virtualchassis_members(instance, **kwargs): # @receiver(trace_paths, sender=Cable) -def update_connected_endpoints(instance, created, raw=False, max_length=None, **kwargs): +def update_connected_endpoints(instance, created, raw=False, **kwargs): """ When a Cable is saved with new terminations, retrace any affected cable paths. """ @@ -95,29 +95,29 @@ def update_connected_endpoints(instance, created, raw=False, max_length=None, ** if not nodes: continue if isinstance(nodes[0], PathEndpoint): - create_cablepath(nodes, max_length=max_length) + create_cablepath(nodes) else: - rebuild_paths(nodes, max_length=max_length) + rebuild_paths(nodes) # Update status of CablePaths if Cable status has been changed elif instance.status != instance._orig_status: if instance.status != LinkStatusChoices.STATUS_CONNECTED: CablePath.objects.filter(_nodes__contains=instance).update(is_active=False) else: - rebuild_paths([instance], max_length=max_length) + rebuild_paths([instance]) @receiver(post_delete, sender=Cable) -def retrace_cable_paths(instance, max_length=None, **kwargs): +def retrace_cable_paths(instance, **kwargs): """ When a Cable is deleted, check for and update its connected endpoints """ for cablepath in CablePath.objects.filter(_nodes__contains=instance): - cablepath.retrace(max_length=max_length) + cablepath.retrace() @receiver(post_delete, sender=CableTermination) -def nullify_connected_endpoints(instance, max_length=None, **kwargs): +def nullify_connected_endpoints(instance, **kwargs): """ Disassociate the Cable from the termination object, and retrace any affected CablePaths. """ @@ -128,15 +128,15 @@ def nullify_connected_endpoints(instance, max_length=None, **kwargs): # Remove the deleted CableTermination if it's one of the path's originating nodes if instance.termination in cablepath.origins: cablepath.origins.remove(instance.termination) - cablepath.retrace(max_length=max_length) + cablepath.retrace() @receiver(post_save, sender=FrontPort) -def extend_rearport_cable_paths(instance, created, raw, max_length=None, **kwargs): +def extend_rearport_cable_paths(instance, created, raw, **kwargs): """ When a new FrontPort is created, add it to any CablePaths which end at its corresponding RearPort. """ if created and not raw: rearport = instance.rear_port for cablepath in CablePath.objects.filter(_nodes__contains=rearport): - cablepath.retrace(max_length=max_length) + cablepath.retrace() diff --git a/netbox/dcim/tests/test_cablepaths.py b/netbox/dcim/tests/test_cablepaths.py index a6b912d58..2de8a1d98 100644 --- a/netbox/dcim/tests/test_cablepaths.py +++ b/netbox/dcim/tests/test_cablepaths.py @@ -2382,9 +2382,9 @@ class CablePathTestCase(TestCase): CableTermination.objects.create(cable=cable_2, cable_end='A', termination_type=ct_frontport, termination_id=front_port_2.id) CableTermination.objects.create(cable=cable_2, cable_end='B', termination_type=ct_rearport, termination_id=rear_splice.id) - max_length = 50 + cable_1.save() - cable_1.save(max_length=max_length) + max_length = 50 a_terminations = [] b_terminations = [] for t in cable_1.terminations.all(): diff --git a/netbox/dcim/utils.py b/netbox/dcim/utils.py index 71064bed9..4d4228490 100644 --- a/netbox/dcim/utils.py +++ b/netbox/dcim/utils.py @@ -30,21 +30,20 @@ def path_node_to_object(repr): return ct.model_class().objects.filter(pk=object_id).first() -def create_cablepath(terminations, max_length=None): +def create_cablepath(terminations): """ Create CablePaths for all paths originating from the specified set of nodes. :param terminations: Iterable of CableTermination objects - :max_length: Optional limit of cable path to trace """ from dcim.models import CablePath - cp = CablePath.from_origin(terminations, max_length=max_length) + cp = CablePath.from_origin(terminations) if cp: cp.save() -def rebuild_paths(terminations, max_length=None): +def rebuild_paths(terminations): """ Rebuild all CablePaths which traverse the specified nodes. """ @@ -56,4 +55,4 @@ def rebuild_paths(terminations, max_length=None): with transaction.atomic(): for cp in cable_paths: cp.delete() - create_cablepath(cp.origins, max_length=max_length) + create_cablepath(cp.origins) diff --git a/netbox/wireless/signals.py b/netbox/wireless/signals.py index 71cd64180..ff7b1229c 100644 --- a/netbox/wireless/signals.py +++ b/netbox/wireless/signals.py @@ -13,7 +13,7 @@ from .models import WirelessLink # @receiver(post_save, sender=WirelessLink) -def update_connected_interfaces(instance, created, raw=False, max_length=None, **kwargs): +def update_connected_interfaces(instance, created, raw=False, **kwargs): """ When a WirelessLink is saved, save a reference to it on each connected interface. """ @@ -34,7 +34,7 @@ def update_connected_interfaces(instance, created, raw=False, max_length=None, * # Create/update cable paths if created: for interface in (instance.interface_a, instance.interface_b): - create_cablepath([interface], max_length=max_length) + create_cablepath([interface]) @receiver(post_delete, sender=WirelessLink)