diff --git a/netbox/dcim/cable_profiles.py b/netbox/dcim/cable_profiles.py index b6fea1cc4..9aa68c821 100644 --- a/netbox/dcim/cable_profiles.py +++ b/netbox/dcim/cable_profiles.py @@ -12,9 +12,9 @@ class BaseCableProfile: # Number of A & B terminations must match symmetrical = True - # Whether to pop the position stack when tracing a cable from this end - pop_stack_a_side = True - pop_stack_b_side = True + # Whether terminations on either side of the cable have a numeric position + a_side_numbered = True + b_side_numbered = True def clean(self, cable): if self.a_max_connections and len(cable.a_terminations) > self.a_max_connections: @@ -52,7 +52,7 @@ class BaseCableProfile: position = None # Pop the position stack if necessary - if (local_end == 'A' and self.pop_stack_a_side) or (local_end == 'B' and self.pop_stack_b_side): + if (local_end == 'A' and self.b_side_numbered) or (local_end == 'B' and self.a_side_numbered): try: position = position_stack.pop()[0] except IndexError: @@ -83,14 +83,14 @@ class AToManyCableProfile(BaseCableProfile): a_max_connections = 1 b_max_connections = None symmetrical = False - pop_stack_b_side = False + a_side_numbered = False class BToManyCableProfile(BaseCableProfile): a_max_connections = None b_max_connections = 1 symmetrical = False - pop_stack_a_side = False + b_side_numbered = False class Shuffle2x2MPOCableProfile(BaseCableProfile): diff --git a/netbox/dcim/choices.py b/netbox/dcim/choices.py index 3d8510eb3..b3e04808a 100644 --- a/netbox/dcim/choices.py +++ b/netbox/dcim/choices.py @@ -1733,20 +1733,6 @@ class CableProfileChoices(ChoiceSet): (SHUFFLE_2X2_MPO, _('Shuffle (2x2 MPO)')), ) - # TODO: Move these designations into the profiles - A_SIDE_NUMBERED = ( - STRAIGHT_SINGLE, - STRAIGHT_MULTI, - B_TO_MANY, - SHUFFLE_2X2_MPO, - ) - B_SIDE_NUMBERED = ( - STRAIGHT_SINGLE, - STRAIGHT_MULTI, - A_TO_MANY, - SHUFFLE_2X2_MPO, - ) - class CableTypeChoices(ChoiceSet): # Copper - Twisted Pair (UTP/STP) diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index 9bfdf0061..3aa916c45 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -327,6 +327,7 @@ class Cable(PrimaryModel): Create/delete CableTerminations for this Cable to reflect its current state. """ a_terminations, b_terminations = self.get_terminations() + profile = self.profile_class if self.profile else None # Delete any stale CableTerminations for termination, ct in a_terminations.items(): @@ -339,11 +340,11 @@ class Cable(PrimaryModel): # Save any new CableTerminations for i, termination in enumerate(self.a_terminations, start=1): if not termination.pk or termination not in a_terminations: - position = i if self.profile in CableProfileChoices.A_SIDE_NUMBERED else None + position = i if profile and profile.a_side_numbered else None CableTermination(cable=self, cable_end='A', position=position, termination=termination).save() for i, termination in enumerate(self.b_terminations, start=1): if not termination.pk or termination not in b_terminations: - position = i if self.profile in CableProfileChoices.B_SIDE_NUMBERED else None + position = i if profile and profile.b_side_numbered else None CableTermination(cable=self, cable_end='B', position=position, termination=termination).save()