diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py index 8da50b612699..bb2f7bdc5ef7 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py @@ -54,8 +54,8 @@ def __initialize_sfp(self): from sonic_platform.sfp import Sfp for index in range(0, NUM_SFP): - name_idx = 0 if index + 1 == NUM_SFP else index + 1 - sfp = Sfp(index, sfputil_helper.logical[name_idx]) + #name_idx = 0 if index + 1 == NUM_SFP else index + 1 + sfp = Sfp(index, sfputil_helper.logical[index]) self._sfp_list.append(sfp) self.sfp_module_initialized = True diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/sfp.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/sfp.py index 8fd7c385e3c2..2da69d793534 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/sfp.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/sfp.py @@ -847,9 +847,9 @@ def get_rx_los(self): A Boolean, True if SFP has RX LOS, False if not. Note : RX LOS status is latched until a call to get_rx_los or a reset. """ - rx_los = False + rx_los = [] if self.sfp_type == OSFP_TYPE: - return False + return rx_los.append(False) elif self.sfp_type == QSFP_TYPE: offset = 0 @@ -861,14 +861,16 @@ def get_rx_los(self): rx2_los = (rx_los_data & 0x02 != 0) rx3_los = (rx_los_data & 0x04 != 0) rx4_los = (rx_los_data & 0x08 != 0) - rx_los = (rx1_los and rx2_los and rx3_los and rx4_los) + #rx_los = (rx1_los and rx2_los and rx3_los and rx4_los) + rx_los.extend([rx1_los, rx2_los, rx3_los, rx4_los]) + return rx_los else: offset = 256 dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + SFP_CHANNL_STATUS_OFFSET), SFP_CHANNL_STATUS_WIDTH) if dom_channel_monitor_raw is not None: rx_los_data = int(dom_channel_monitor_raw[0], 16) - rx_los = (rx_los_data & 0x02 != 0) + rx_los.append(rx_los_data & 0x02 != 0) return rx_los @@ -879,10 +881,10 @@ def get_tx_fault(self): A Boolean, True if SFP has TX fault, False if not Note : TX fault status is lached until a call to get_tx_fault or a reset. """ - tx4_fault = False + tx_fault_list = [] if self.sfp_type == OSFP_TYPE or not self.dom_supported: - return False + return tx_fault_list.append(False) elif self.sfp_type == QSFP_TYPE: offset = 0 @@ -894,17 +896,17 @@ def get_tx_fault(self): tx2_fault = (tx_fault_data & 0x02 != 0) tx3_fault = (tx_fault_data & 0x04 != 0) tx4_fault = (tx_fault_data & 0x08 != 0) - tx4_fault = ( - tx1_fault and tx2_fault and tx3_fault and tx4_fault) + tx_fault_list.extend([tx1_fault, tx2_fault, tx3_fault, + tx4_fault]) else: offset = 256 dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + SFP_CHANNL_STATUS_OFFSET), SFP_CHANNL_STATUS_WIDTH) if dom_channel_monitor_raw is not None: tx_fault_data = int(dom_channel_monitor_raw[0], 16) - tx4_fault = (tx_fault_data & 0x04 != 0) + tx_fault_list.append(tx_fault_data & 0x04 != 0) - return tx4_fault + return tx_fault_list def get_tx_disable(self): """ @@ -1357,3 +1359,18 @@ def get_status(self): A boolean value, True if device is operating properly, False if not """ return self.get_presence() and not self.get_reset_status() + + def get_position_in_parent(self): + """ + Returns: + Temp return 0 + """ + return 0 + + def is_replaceable(self): + """ + Retrieves if replaceable + Returns: + A boolean value, True if replaceable + """ + return True diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py index 2b38ef94d6c4..f6568c0cebe0 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py @@ -7,7 +7,6 @@ ############################################################################# import os -import re import os.path try: @@ -19,14 +18,18 @@ THERMAL_INFO = { 0: { "F2B_max": 50, + "F2B_max_crit": 75, "B2F_max": 55, + "B2F_max_crit": 75, "postion": "asic", "name": "Front-panel temp sensor 1", "i2c_path": "i2c-5/5-0048/hwmon/hwmon1", # u4 system-inlet }, 1: { "F2B_max": 50, + "F2B_max_crit": 75, "B2F_max": 55, + "B2F_max_crit": 75, "postion": "asic", "name": "Front-panel temp sensor 2", "i2c_path": "i2c-6/6-0049/hwmon/hwmon2", # u2 system-inlet @@ -51,7 +54,9 @@ }, 4: { "F2B_max": 70, + "F2B_max_crit": 75, "B2F_max": 55, + "B2F_max_crit": 75, "postion": "cpu", "name": "Rear-panel temp sensor 2", "i2c_path": "i2c-15/15-004e/hwmon/hwmon5" # u9201 system-outlet @@ -71,8 +76,7 @@ def __init__(self, thermal_index, airflow): self._api_helper = APIHelper() self._airflow = airflow self._thermal_info = THERMAL_INFO[self.index] - self._hwmon_path = "{}/{}".format(I2C_ADAPTER_PATH, - self._thermal_info["i2c_path"]) + self._hwmon_path = "{}/{}".format(I2C_ADAPTER_PATH, self._thermal_info["i2c_path"]) self.name = self.get_name() self.postion = self._thermal_info["postion"] self.ss_index = 1 @@ -109,8 +113,9 @@ def get_high_threshold(self): A float number, the high threshold temperature of thermal in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - max_crit_key = '{}_max'.format(self._airflow) - return self._thermal_info.get(max_crit_key, None) + temp_file = "temp{}_max".format(self.ss_index) + temp = float(self.__get_temp(temp_file)) + return temp def get_low_threshold(self): """ @@ -119,7 +124,7 @@ def get_low_threshold(self): A float number, the low threshold temperature of thermal in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - return 0.0 + return 0.001 def set_high_threshold(self, temperature): """ @@ -132,31 +137,33 @@ def set_high_threshold(self, temperature): """ temp_file = "temp{}_max".format(self.ss_index) is_set = self.__set_threshold(temp_file, int(temperature*1000)) - file_set = False - if is_set: - try: - with open(self.SS_CONFIG_PATH, 'r+') as f: - content = f.readlines() - f.seek(0) - ss_found = False - for idx, val in enumerate(content): - if self.name in val: - ss_found = True - elif ss_found and temp_file in val: - content[idx] = " set {} {}\n".format( - temp_file, temperature) - f.writelines(content) - file_set = True - break - except IOError: - file_set = False + file_set = True + if self._api_helper.is_host(): + file_set = False + if is_set: + try: + with open(self.SS_CONFIG_PATH, 'r+') as f: + content = f.readlines() + f.seek(0) + ss_found = False + for idx, val in enumerate(content): + if self.name in val: + ss_found = True + elif ss_found and temp_file in val: + content[idx] = " set {} {}\n".format( + temp_file, temperature) + f.writelines(content) + file_set = True + break + except IOError as err: + file_set = False return is_set & file_set def set_low_threshold(self, temperature): """ Sets the low threshold temperature of thermal - Args : + Args : temperature: A float number up to nearest thousandth of one degree Celsius, e.g. 30.125 Returns: @@ -172,7 +179,10 @@ def get_high_critical_threshold(self): up to nearest thousandth of one degree Celsius, e.g. 30.125 """ max_crit_key = '{}_max_crit'.format(self._airflow) - return self._thermal_info.get(max_crit_key, None) + max_crit_threshold = self._thermal_info.get(max_crit_key, None) + if max_crit_threshold is not None: + max_crit_threshold = float(max_crit_threshold) + return max_crit_threshold def get_low_critical_threshold(self): """ @@ -181,7 +191,7 @@ def get_low_critical_threshold(self): A float number, the low critical threshold temperature of thermal in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - return 0.0 + return 0.001 def get_name(self): """ @@ -233,3 +243,21 @@ def get_status(self): raw_txt = self.__read_txt_file(fault_file_path) return int(raw_txt) == 0 + + def is_replaceable(self): + """ + Retrieves whether thermal module is replaceable + Returns: + A boolean value, True if replaceable, False if not + """ + return False + + def get_position_in_parent(self): + """ + Retrieves the thermal position information + Returns: + A int value, 0 represent ASIC thermal, 1 represent CPU thermal info + """ + if self.postion == "cpu": + return 1 + return 0