diff --git a/sonic_platform_base/chassis_base.py b/sonic_platform_base/chassis_base.py index 05a633596..27f6f6967 100644 --- a/sonic_platform_base/chassis_base.py +++ b/sonic_platform_base/chassis_base.py @@ -280,26 +280,60 @@ def get_module_index(self, module_name): # SmartSwitch methods ############################################## - def get_dpu_id(self, name): + def get_dpu_id(self, **kwargs): """ - Retrieves the DPU ID for the given dpu-module name. - Returns None for non-smartswitch chassis. + Retrieves the DPU ID for the specified DPU module on a Smart Switch chassis. + + When run on the Smart Switch chassis, it fetches the ID corresponding to provided DPU module name. + When run on the Smart Switch DPU chassis, returns the ID of the DPU. + This method is relevant only for Smart Switch chassis. + + Args: + name (str, optional): The name of the DPU module (e.g., "DPU0", "DPU1"). Returns: - An integer, indicating the DPU ID Ex: name:DPU0 return value 0, - name:DPU1 return value 1, name:DPUX return value X + int: The DPU ID associated with the given module name. + For example, for name "DPU0", returns 0; for "DPU1", returns 1, and so on. """ raise NotImplementedError def is_smartswitch(self): """ - Retrieves whether the sonic instance is part of smartswitch + Checks whether the current SONiC instance is part of a Smart Switch platform. Returns: - Returns:True for SmartSwitch and False for other platforms + bool: True if the instance is part of a Smart Switch, False otherwise. """ return False + def is_dpu(self): + """ + Checks whether the current SONiC instance is running on a DPU. + + Returns: + bool: True if the instance is running on a DPU, False otherwise. + """ + return False + + def get_dataplane_state(self): + """ + Retrieves the status of the dataplane. + + Returns: + bool: True if the dataplane is UP, False if it is down. + """ + raise NotImplementedError + + def get_controlplane_state(self): + """ + Retrieves the status of the DPU control plane. + + Returns: + bool: True if the control plane is UP, False if it is down. + """ + raise NotImplementedError + + ############################################## # Fan methods ############################################## diff --git a/tests/chassis_base_test.py b/tests/chassis_base_test.py index c7dbc512e..2e3dc85a0 100644 --- a/tests/chassis_base_test.py +++ b/tests/chassis_base_test.py @@ -20,17 +20,20 @@ def test_reboot_cause(self): def test_chassis_base(self): chassis = ChassisBase() not_implemented_methods = [ - [chassis.get_uid_led], - [chassis.set_uid_led, "COLOR"], - [chassis.get_dpu_id, "DPU0"], + [chassis.get_uid_led, [], {}], + [chassis.set_uid_led, ["COLOR"], {}], + [chassis.get_dpu_id, [], {"name": "DPU0"}], + [chassis.get_dataplane_state, [], {}], + [chassis.get_controlplane_state, [], {}], ] for method in not_implemented_methods: exception_raised = False try: func = method[0] - args = method[1:] - func(*args) + args = method[1] + kwargs = method[2] + func(*args, **kwargs) except NotImplementedError: exception_raised = True @@ -39,6 +42,7 @@ def test_chassis_base(self): def test_smartswitch(self): chassis = ChassisBase() assert(chassis.is_smartswitch() == False) + assert(chassis.is_dpu() == False) def test_sensors(self): chassis = ChassisBase()