From b70e75979f704e980a3fb20732642ec99f32b0ee Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Mon, 11 Apr 2022 22:02:01 +0800 Subject: [PATCH] support new reboot-cause (#277) - Description Add some new reboot causes to cover followinging scenarios: BIOS - In case the BIOS upgrade process ended with failure and cause the switch to reset. CPU - Reset is initiated by SW on the CPU. it could be that SW encountered some catastrophic situation like a memory leak, eventually, the kernel reset the whole switch. Push button - Reset by pushing the reset button Reset from ASIC - Reset which is caused by ASIC. Motivation and Context Add more reboot causes to cover more scenarios. - How Has This Been Tested? UT is added with the code change. Run community reboot test to see the reboot cause checker can pass. Signed-off-by: Kebo Liu --- sonic_platform_base/chassis_base.py | 4 ++++ tests/chassis_base_test.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/chassis_base_test.py diff --git a/sonic_platform_base/chassis_base.py b/sonic_platform_base/chassis_base.py index 96cec9e9ec51..e793a7bd1e90 100644 --- a/sonic_platform_base/chassis_base.py +++ b/sonic_platform_base/chassis_base.py @@ -24,6 +24,10 @@ class ChassisBase(device_base.DeviceBase): REBOOT_CAUSE_INSUFFICIENT_FAN_SPEED = "Insufficient Fan Speed" REBOOT_CAUSE_WATCHDOG = "Watchdog" REBOOT_CAUSE_HARDWARE_OTHER = "Hardware - Other" + REBOOT_CAUSE_HARDWARE_BIOS = "BIOS" + REBOOT_CAUSE_HARDWARE_CPU = "CPU" + REBOOT_CAUSE_HARDWARE_BUTTON = "Push button" + REBOOT_CAUSE_HARDWARE_RESET_FROM_ASIC = "Reset from ASIC" REBOOT_CAUSE_NON_HARDWARE = "Non-Hardware" def __init__(self): diff --git a/tests/chassis_base_test.py b/tests/chassis_base_test.py new file mode 100644 index 000000000000..c2f2e5f97915 --- /dev/null +++ b/tests/chassis_base_test.py @@ -0,0 +1,18 @@ +from sonic_platform_base.chassis_base import ChassisBase + +class TestChassisBase: + + def test_reboot_cause(self): + chassis = ChassisBase() + assert(chassis.REBOOT_CAUSE_POWER_LOSS == "Power Loss") + assert(chassis.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU == "Thermal Overload: CPU") + assert(chassis.REBOOT_CAUSE_THERMAL_OVERLOAD_ASIC == "Thermal Overload: ASIC") + assert(chassis.REBOOT_CAUSE_THERMAL_OVERLOAD_OTHER == "Thermal Overload: Other") + assert(chassis.REBOOT_CAUSE_INSUFFICIENT_FAN_SPEED == "Insufficient Fan Speed") + assert(chassis.REBOOT_CAUSE_WATCHDOG == "Watchdog") + assert(chassis.REBOOT_CAUSE_HARDWARE_OTHER == "Hardware - Other") + assert(chassis.REBOOT_CAUSE_HARDWARE_BIOS == "BIOS") + assert(chassis.REBOOT_CAUSE_HARDWARE_CPU == "CPU") + assert(chassis.REBOOT_CAUSE_HARDWARE_BUTTON == "Push button") + assert(chassis.REBOOT_CAUSE_HARDWARE_RESET_FROM_ASIC == "Reset from ASIC") + assert(chassis.REBOOT_CAUSE_NON_HARDWARE == "Non-Hardware")