Skip to content

Commit

Permalink
support new reboot-cause (#277)
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
keboliu authored Apr 11, 2022
1 parent 01512ec commit b70e759
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sonic_platform_base/chassis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 18 additions & 0 deletions tests/chassis_base_test.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit b70e759

Please sign in to comment.