Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning/critical thresholds for PSU power #304

Merged
merged 4 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
stephenxs marked this conversation as resolved.
Show resolved Hide resolved
"""
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