From 7c48be2cc837f75bfa938229ec6df4b5010fe30b Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Tue, 22 Nov 2022 06:52:02 +0800 Subject: [PATCH] Add warning/critical thresholds for PSU power (#304) Add warning/critical thresholds for PSU power Signed-off-by: Stephen Sun --- sonic_platform_base/psu_base.py | 20 ++++++++++++++++++++ tests/psu_base_test.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/psu_base_test.py diff --git a/sonic_platform_base/psu_base.py b/sonic_platform_base/psu_base.py index 63b1a7ef27ff..98aebec8ef00 100644 --- a/sonic_platform_base/psu_base.py +++ b/sonic_platform_base/psu_base.py @@ -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): """ diff --git a/tests/psu_base_test.py b/tests/psu_base_test.py new file mode 100644 index 000000000000..6c1e079eb29a --- /dev/null +++ b/tests/psu_base_test.py @@ -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