From e3cfc4435423f18ea1cf0a58be3c1e47dc13d7bb Mon Sep 17 00:00:00 2001 From: dflynn-Nokia <60479697+dflynn-Nokia@users.noreply.github.com> Date: Sat, 11 Sep 2021 04:18:24 -0400 Subject: [PATCH] [Nokia ixs7215] Miscellaneous platform API fixes (#8707) * [Nokia ixs7215] Miscellaneous platform API fixes This commit delivers the following fixes for the Nokia ixs7215 platform - Fix bug in a fan API error path - Add support for setting the fan drawer led - Add support for getting/setting the front panel PSU status led - Add support for getting the min/max observed temperature value * [Nokia ixs7215] code review changes: temperature min/max values --- .../7215/sonic_platform/fan.py | 12 ++++------- .../7215/sonic_platform/fan_drawer.py | 2 +- .../7215/sonic_platform/psu.py | 20 +++++++++++++++++++ .../7215/sonic_platform/thermal.py | 15 ++++++++++++++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py index 14c00c763d..b8fd335930 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py @@ -336,10 +336,10 @@ class Fan(FanBase): """ if self.is_psu_fan: - return False + return None if smbus_present == 0: - return False + return None else: bus = smbus.SMBus(0) DEVICE_ADDRESS = 0x41 @@ -368,7 +368,7 @@ class Fan(FanBase): (off) to 100 (full speed) """ speed = 0 - + fan_duty = self._get_i2c_register(self.set_fan_speed_reg) if (fan_duty != 'ERR'): dutyspeed = int(fan_duty) @@ -380,9 +380,5 @@ class Fan(FanBase): speed = 50 elif dutyspeed == 255: speed = 100 - + return speed - - - - diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py index 35b663cbb7..e42d80cdbd 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py @@ -54,7 +54,7 @@ class NokiaFanDrawer(FanDrawerBase): return 'intake' def set_status_led(self, color): - return True + return self._fan_list[0].set_status_led(color) def get_status_led(self, color): return self._fan_list[0].get_status_led() diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py index 6a338f5a16..90025db7ff 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py @@ -234,3 +234,23 @@ class Psu(PsuBase): # The firmware running in the PSU controls the LED # and the PSU LED state cannot be changed from CPU. return False + + def get_status_master_led(self): + """ + Gets the state of the front panel PSU status LED + + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings. + """ + return self._psu_master_led_color + + def set_status_master_led(self, color): + """ + Sets the state of the front panel PSU status LED + + Returns: + bool: True if status LED state is set successfully, False if + not + """ + self._psu_master_led_color = color + return True diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/thermal.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/thermal.py index 528a6e49d9..20fdec61f3 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/thermal.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/thermal.py @@ -33,9 +33,12 @@ class Thermal(ThermalBase): "CPU Core") def __init__(self, thermal_index): + ThermalBase.__init__(self) self.index = thermal_index + 1 self.is_psu_thermal = False self.dependency = None + self._minimum = None + self._maximum = None self.thermal_high_threshold_file = None # PCB temperature sensors if self.index < 3: @@ -163,6 +166,10 @@ class Thermal(ThermalBase): self.thermal_temperature_file) if (thermal_temperature != 'ERR'): thermal_temperature = float(thermal_temperature) / 1000 + if self._minimum is None or self._minimum > thermal_temperature: + self._minimum = thermal_temperature + if self._maximum is None or self._maximum < thermal_temperature: + self._maximum = thermal_temperature else: thermal_temperature = 0 @@ -226,6 +233,14 @@ class Thermal(ThermalBase): return float("{:.3f}".format(thermal_high_crit_threshold)) + def get_minimum_recorded(self): + self.get_temperature() + return self._minimum + + def get_maximum_recorded(self): + self.get_temperature() + return self._maximum + def get_position_in_parent(self): """ Retrieves 1-based relative physical position in parent device