From 481811e487ed4999ad3a8e0c39c7425e5a7dee16 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 14 Nov 2025 08:59:49 -0500 Subject: [PATCH] Misc cleanup --- netbox/dcim/cable_profiles.py | 15 +-------------- netbox/dcim/choices.py | 12 ++++-------- netbox/dcim/constants.py | 4 ++-- netbox/dcim/models/cables.py | 7 +++---- netbox/dcim/models/device_components.py | 4 ++-- 5 files changed, 12 insertions(+), 30 deletions(-) diff --git a/netbox/dcim/cable_profiles.py b/netbox/dcim/cable_profiles.py index 35e262365..353b64626 100644 --- a/netbox/dcim/cable_profiles.py +++ b/netbox/dcim/cable_profiles.py @@ -88,20 +88,7 @@ class BToManyCableProfile(BaseCableProfile): pop_stack_b_side = False -class Shuffle4x4CableProfile(BaseCableProfile): - a_max_connections = 4 - b_max_connections = 4 - - def get_mapped_position(self, position): - return { - 1: 1, - 2: 3, - 3: 2, - 4: 4, - }.get(position) - - -class Shuffle8x8CableProfile(BaseCableProfile): +class Shuffle2x2MPOCableProfile(BaseCableProfile): a_max_connections = 8 b_max_connections = 8 diff --git a/netbox/dcim/choices.py b/netbox/dcim/choices.py index 8f59d47ba..3d8510eb3 100644 --- a/netbox/dcim/choices.py +++ b/netbox/dcim/choices.py @@ -1722,8 +1722,7 @@ class CableProfileChoices(ChoiceSet): STRAIGHT_MULTI = 'straight-multi' A_TO_MANY = 'a-to-many' B_TO_MANY = 'b-to-many' - SHUFFLE_4X4 = 'shuffle-4x4' - SHUFFLE_8X8 = 'shuffle-8x8' + SHUFFLE_2X2_MPO = 'shuffle-2x2-mpo' CHOICES = ( (STRAIGHT_SINGLE, _('Straight (single position)')), @@ -1731,8 +1730,7 @@ class CableProfileChoices(ChoiceSet): # TODO: Better names for many-to-one profiles? (A_TO_MANY, _('A to many')), (B_TO_MANY, _('B to many')), - (SHUFFLE_4X4, _('Shuffle (4x4)')), - (SHUFFLE_8X8, _('Shuffle (8x8)')), + (SHUFFLE_2X2_MPO, _('Shuffle (2x2 MPO)')), ) # TODO: Move these designations into the profiles @@ -1740,15 +1738,13 @@ class CableProfileChoices(ChoiceSet): STRAIGHT_SINGLE, STRAIGHT_MULTI, B_TO_MANY, - SHUFFLE_4X4, - SHUFFLE_8X8, + SHUFFLE_2X2_MPO, ) B_SIDE_NUMBERED = ( STRAIGHT_SINGLE, STRAIGHT_MULTI, A_TO_MANY, - SHUFFLE_4X4, - SHUFFLE_8X8, + SHUFFLE_2X2_MPO, ) diff --git a/netbox/dcim/constants.py b/netbox/dcim/constants.py index 92b58cef3..5e4311c13 100644 --- a/netbox/dcim/constants.py +++ b/netbox/dcim/constants.py @@ -24,8 +24,8 @@ RACK_STARTING_UNIT_DEFAULT = 1 # Cables # -CABLETERMINATION_POSITION_MIN = 1 -CABLETERMINATION_POSITION_MAX = 1024 +CABLE_POSITION_MIN = 1 +CABLE_POSITION_MAX = 1024 # diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index 530863066..9bfdf0061 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -138,8 +138,7 @@ class Cable(PrimaryModel): CableProfileChoices.STRAIGHT_MULTI: cable_profiles.StraightMultiCableProfile, CableProfileChoices.A_TO_MANY: cable_profiles.AToManyCableProfile, CableProfileChoices.B_TO_MANY: cable_profiles.BToManyCableProfile, - CableProfileChoices.SHUFFLE_4X4: cable_profiles.Shuffle4x4CableProfile, - CableProfileChoices.SHUFFLE_8X8: cable_profiles.Shuffle8x8CableProfile, + CableProfileChoices.SHUFFLE_2X2_MPO: cable_profiles.Shuffle2x2MPOCableProfile, }.get(self.profile) def _get_x_terminations(self, side): @@ -376,8 +375,8 @@ class CableTermination(ChangeLoggedModel): blank=True, null=True, validators=( - MinValueValidator(CABLETERMINATION_POSITION_MIN), - MaxValueValidator(CABLETERMINATION_POSITION_MAX) + MinValueValidator(CABLE_POSITION_MIN), + MaxValueValidator(CABLE_POSITION_MAX) ) ) diff --git a/netbox/dcim/models/device_components.py b/netbox/dcim/models/device_components.py index 9ed982da4..8c9acc48f 100644 --- a/netbox/dcim/models/device_components.py +++ b/netbox/dcim/models/device_components.py @@ -180,8 +180,8 @@ class CabledObjectModel(models.Model): blank=True, null=True, validators=( - MinValueValidator(CABLETERMINATION_POSITION_MIN), - MaxValueValidator(CABLETERMINATION_POSITION_MAX) + MinValueValidator(CABLE_POSITION_MIN), + MaxValueValidator(CABLE_POSITION_MAX) ), ) mark_connected = models.BooleanField(