Skip to content

Commit

Permalink
Add warning/critical thresholds for PSU power (#304)
Browse files Browse the repository at this point in the history
Add warning/critical thresholds for PSU power

Signed-off-by: Stephen Sun <[email protected]>
  • Loading branch information
stephenxs authored Nov 21, 2022
1 parent f5ba0d0 commit 7c48be2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
20 changes: 20 additions & 0 deletions sonic_platform_base/psu_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,26 @@ def get_maximum_supplied_power(self):
"""
raise NotImplementedError

def get_psu_power_warning_suppress_threshold(self):
"""
Retrieve the warning suppress threshold of the power on this PSU
The value can be volatile, so the caller should call the API each time it is used.
Returns:
A float number, the warning suppress threshold of the PSU in watts.
"""
raise NotImplementedError

def get_psu_power_critical_threshold(self):
"""
Retrieve the critical threshold of the power on this PSU
The value can be volatile, so the caller should call the API each time it is used.
Returns:
A float number, the critical threshold of the PSU in watts.
"""
raise NotImplementedError

@classmethod
def get_status_master_led(cls):
"""
Expand Down
29 changes: 29 additions & 0 deletions tests/psu_base_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from sonic_platform_base.psu_base import PsuBase

class TestPsuBase:

def test_psu_base(self):
psu = PsuBase()
not_implemented_methods = [
psu.get_voltage,
psu.get_current,
psu.get_power,
psu.get_powergood_status,
psu.get_temperature,
psu.get_temperature_high_threshold,
psu.get_voltage_high_threshold,
psu.get_voltage_low_threshold,
psu.get_maximum_supplied_power,
psu.get_psu_power_warning_suppress_threshold,
psu.get_psu_power_critical_threshold,
psu.get_input_voltage,
psu.get_input_current]

for method in not_implemented_methods:
exception_raised = False
try:
method()
except NotImplementedError:
exception_raised = True

assert exception_raised

0 comments on commit 7c48be2

Please sign in to comment.