Skip to content

Commit 7c48be2

Browse files
authored
Add warning/critical thresholds for PSU power (#304)
Add warning/critical thresholds for PSU power Signed-off-by: Stephen Sun <[email protected]>
1 parent f5ba0d0 commit 7c48be2

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

sonic_platform_base/psu_base.py

+20
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,26 @@ def get_maximum_supplied_power(self):
223223
"""
224224
raise NotImplementedError
225225

226+
def get_psu_power_warning_suppress_threshold(self):
227+
"""
228+
Retrieve the warning suppress threshold of the power on this PSU
229+
The value can be volatile, so the caller should call the API each time it is used.
230+
231+
Returns:
232+
A float number, the warning suppress threshold of the PSU in watts.
233+
"""
234+
raise NotImplementedError
235+
236+
def get_psu_power_critical_threshold(self):
237+
"""
238+
Retrieve the critical threshold of the power on this PSU
239+
The value can be volatile, so the caller should call the API each time it is used.
240+
241+
Returns:
242+
A float number, the critical threshold of the PSU in watts.
243+
"""
244+
raise NotImplementedError
245+
226246
@classmethod
227247
def get_status_master_led(cls):
228248
"""

tests/psu_base_test.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from sonic_platform_base.psu_base import PsuBase
2+
3+
class TestPsuBase:
4+
5+
def test_psu_base(self):
6+
psu = PsuBase()
7+
not_implemented_methods = [
8+
psu.get_voltage,
9+
psu.get_current,
10+
psu.get_power,
11+
psu.get_powergood_status,
12+
psu.get_temperature,
13+
psu.get_temperature_high_threshold,
14+
psu.get_voltage_high_threshold,
15+
psu.get_voltage_low_threshold,
16+
psu.get_maximum_supplied_power,
17+
psu.get_psu_power_warning_suppress_threshold,
18+
psu.get_psu_power_critical_threshold,
19+
psu.get_input_voltage,
20+
psu.get_input_current]
21+
22+
for method in not_implemented_methods:
23+
exception_raised = False
24+
try:
25+
method()
26+
except NotImplementedError:
27+
exception_raised = True
28+
29+
assert exception_raised

0 commit comments

Comments
 (0)