From 3a1f7ec282c7a33c2323e2e53a6e87ac12c12340 Mon Sep 17 00:00:00 2001 From: shreyansh-nexthop Date: Tue, 4 Aug 2026 06:50:47 +0000 Subject: [PATCH 1/2] Provide BMC defaults for system status LED methods in ChassisBase `show system-health` (sonic-utilities) calls initizalize_system_led(), set_status_led() and get_status_led() unconditionally on the chassis, but BMC platforms have no controllable system status LED. ChassisBase left set/get as NotImplementedError and had no initizalize_system_led at all, so the CLI failed on BMC images. Provide BMC defaults in ChassisBase, gated on is_switch_bmc(): initizalize_system_led() returns True, set_status_led() returns False, and get_status_led() returns "N/A". Non-BMC platforms are unaffected: they fall through to NotImplementedError as before, or override these methods. Signed-off-by: shreyansh-nexthop --- sonic_platform_base/chassis_base.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sonic_platform_base/chassis_base.py b/sonic_platform_base/chassis_base.py index db865e753..b9ee9f57f 100644 --- a/sonic_platform_base/chassis_base.py +++ b/sonic_platform_base/chassis_base.py @@ -878,6 +878,18 @@ def get_port_or_cage_type(self, index): # System LED methods ############################################## + def initizalize_system_led(self): + """ + Initialize the system status LED. + + Returns: + bool: True if the system LED was initialized successfully. + """ + if device_info.is_switch_bmc(): + # BMC platforms have no controllable system LED, nothing to initialize. + return True + raise NotImplementedError + def set_status_led(self, color): """ Sets the state of the system LED @@ -889,6 +901,9 @@ def set_status_led(self, color): Returns: bool: True if system LED state is set successfully, False if not """ + if device_info.is_switch_bmc(): + # BMC platforms have no controllable system LED. + return False raise NotImplementedError def get_status_led(self): @@ -899,6 +914,9 @@ def get_status_led(self): A string, one of the valid LED color strings which could be vendor specified. """ + if device_info.is_switch_bmc(): + # BMC platforms have no controllable system LED. + return "N/A" raise NotImplementedError ############################################## From ca02be558dabaaf0d2c41ed90cf5e48d19547aea Mon Sep 17 00:00:00 2001 From: shreyansh-nexthop Date: Tue, 4 Aug 2026 09:18:48 +0000 Subject: [PATCH 2/2] Add unit tests for the ChassisBase system LED BMC defaults Cover both branches of initizalize_system_led(), set_status_led() and get_status_led(): the BMC defaults when is_switch_bmc() is true, and the NotImplementedError path for non-BMC platforms. Signed-off-by: shreyansh-nexthop --- tests/chassis_base_test.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/chassis_base_test.py b/tests/chassis_base_test.py index 685eacd81..9303a3626 100644 --- a/tests/chassis_base_test.py +++ b/tests/chassis_base_test.py @@ -50,6 +50,37 @@ def test_chassis_base(self): assert exception_raised + @mock.patch('sonic_py_common.device_info.is_switch_bmc', return_value=True) + def test_system_led_bmc(self, _mock_is_switch_bmc): + # BMC platforms have no controllable system LED, so the base class + # provides no-op defaults instead of raising NotImplementedError. + chassis = ChassisBase() + assert(chassis.initizalize_system_led() == True) + assert(chassis.set_status_led("green") == False) + assert(chassis.get_status_led() == "N/A") + + @mock.patch('sonic_py_common.device_info.is_switch_bmc', return_value=False) + def test_system_led_non_bmc(self, _mock_is_switch_bmc): + # Non-BMC platforms are expected to implement these themselves. + chassis = ChassisBase() + not_implemented_methods = [ + [chassis.initizalize_system_led, [], {}], + [chassis.set_status_led, ["COLOR"], {}], + [chassis.get_status_led, [], {}], + ] + + for method in not_implemented_methods: + exception_raised = False + try: + func = method[0] + args = method[1] + kwargs = method[2] + func(*args, **kwargs) + except NotImplementedError: + exception_raised = True + + assert exception_raised + def test_smartswitch(self): chassis = ChassisBase() assert(chassis.is_smartswitch() == False)