From 403743ebaa50620cf67f3c3db87377cd6a1b244f Mon Sep 17 00:00:00 2001 From: Vadym Yashchenko Date: Fri, 3 Dec 2021 07:03:50 -0800 Subject: [PATCH] Signed-off-by: Vadym Yashchenko What I did Add get_model() function Add get_low_critical_threshold() function Change __get(...) function. How I did it Differnece from previous implementation of __get(...) function is return real value or -9999.9 if value is not provided by thrift API --- .../sonic_platform/thermal.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py index 3a39c10a1e1f..28c9139bb104 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py @@ -76,18 +76,27 @@ def __init__(self, chip, label): def __get(self, attr_prefix, attr_suffix): sensor_data = _sensors_get().get(self.__chip, {}).get(self.__label, {}) value = _value_get(sensor_data, attr_prefix, attr_suffix) - if value is not None: return value - raise NotImplementedError + if value is not None: + return value + else: + return -999.9 # ThermalBase interface methods: def get_temperature(self) -> float: return float(self.__get('temp', 'input')) - + def get_high_threshold(self) -> float: return float(self.__get('temp', 'max')) + def get_high_critical_threshold(self) -> float: return float(self.__get('temp', 'crit')) + + def get_low_critical_threshold(self) -> float: + return float(self.__get('temp', 'alarm')) + + def get_model(self): + return f"{self.__label}".lower() # DeviceBase interface methods: def get_name(self):