[device/celestica]: Fix remaining failed test cases of Seastone-DX010 platform API (#7743)

**- Why I did it**
- To fix failed test cases of Seastone-DX010 platform APIs that found on [platform_tests](https://github.com/Azure/sonic-mgmt/tree/master/tests/platform_tests/api) script

**- How I did it**
1. Add device/celestica/x86_64-cel_seastone-r0/platform.json 
2. Update functions to support python3.7
3. Add more functions follow latest sonic_platform_base
4. Fix the bug
This commit is contained in:
Wirut Getbamrung 2021-05-29 02:56:09 +07:00 committed by GitHub
parent 21b9fccd75
commit 4ae6d3f5c9
No account linked to committer's email address
4 changed files with 203 additions and 75 deletions

View File

@ -0,0 +1,13 @@
{
"chassis": {
"Celestica-DX010-C32": {
"component": {
"CPLD1": {},
"CPLD2": {},
"CPLD3": {},
"CPLD4": {},
"BIOS": {}
}
}
}
}

View File

@ -106,6 +106,29 @@ class Component(ComponentBase):
return fw_version
def get_available_firmware_version(self, image_path):
"""
Retrieves the available firmware version of the component
Note: the firmware version will be read from image
Args:
image_path: A string, path to firmware image
Returns:
A string containing the available firmware version of the component
"""
return "N/A"
def get_firmware_update_notification(self, image_path):
"""
Retrieves a notification on what should be done in order to complete
the component firmware update
Args:
image_path: A string, path to firmware image
Returns:
A string containing the component firmware update notification if required.
By default 'None' value will be used, which indicates that no actions are required
"""
return "None"
def install_firmware(self, image_path):
"""
Install firmware to module
@ -130,6 +153,20 @@ class Component(ComponentBase):
return self.__run_command(install_command)
def update_firmware(self, image_path):
"""
Updates firmware of the component
This API performs firmware update: it assumes firmware installation and loading in a single call.
In case platform component requires some extra steps (apart from calling Low Level Utility)
to load the installed firmware (e.g, reboot, power cycle, etc.) - this will be done automatically by API
Args:
image_path: A string, path to firmware image
Raises:
RuntimeError: update failed
"""
return False
##############################################################
###################### Device methods ########################
##############################################################

View File

@ -226,72 +226,6 @@ class Psu(PsuBase):
return status_str
def get_name(self):
"""
Retrieves the name of the device
Returns:
string: The name of the device
"""
return PSU_NAME_LIST[self.index]
def get_presence(self):
"""
Retrieves the presence of the PSU
Returns:
bool: True if PSU is present, False if not
"""
raw = self.__get_gpio_value(self.dx010_psu_gpio[self.index + 1]['prs'])
return int(raw, 10) == 0
def get_status(self):
"""
Retrieves the operational status of the device
Returns:
A boolean value, True if device is operating properly, False if not
"""
raw = self.__get_gpio_value(
self.dx010_psu_gpio[self.index + 1]['status'])
return int(raw, 10) == 1
def get_model(self):
"""
Retrieves the model number (or part number) of the device
Returns:
string: Model/part number of device
"""
model = self.read_fru(self.eeprom_addr, TLV_ATTR_TYPE_MODEL)
if not model:
return "N/A"
return model
def get_serial(self):
"""
Retrieves the serial number of the device
Returns:
string: Serial number of device
"""
serial = self.read_fru(self.eeprom_addr, TLV_ATTR_TYPE_SERIAL)
if not serial:
return "N/A"
return serial
def get_position_in_parent(self):
"""
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position
for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned
Returns:
integer: The 1-based relative physical position in parent device or -1 if cannot determine the position
"""
return -1
def is_replaceable(self):
"""
Indicate whether this device is replaceable.
Returns:
bool: True if it is replaceable.
"""
return True
def get_temperature(self):
"""
Retrieves current temperature reading from PSU
@ -389,3 +323,97 @@ class Psu(PsuBase):
psu_voltage = float(vout_val) / 1000
return psu_voltage
def get_maximum_supplied_power(self):
"""
Retrieves the maximum supplied power by PSU
Returns:
A float number, the maximum power output in Watts.
e.g. 1200.1
"""
psu_power = 0.0
current_name = "power{}_max"
current_label = "pout1"
pw_label_path = self.__search_file_by_contain(
self.hwmon_path, current_label, "power")
if pw_label_path:
dir_name = os.path.dirname(pw_label_path)
basename = os.path.basename(pw_label_path)
pw_num = ''.join(list(filter(str.isdigit, basename)))
pw_path = os.path.join(
dir_name, current_name.format(pw_num))
pw_val = self._api_helper.read_txt_file(pw_path)
psu_power = float(pw_val) / 1000000
return psu_power
##############################################################
###################### Device methods ########################
##############################################################
def get_name(self):
"""
Retrieves the name of the device
Returns:
string: The name of the device
"""
return PSU_NAME_LIST[self.index]
def get_presence(self):
"""
Retrieves the presence of the PSU
Returns:
bool: True if PSU is present, False if not
"""
raw = self.__get_gpio_value(self.dx010_psu_gpio[self.index + 1]['prs'])
return int(raw, 10) == 0
def get_status(self):
"""
Retrieves the operational status of the device
Returns:
A boolean value, True if device is operating properly, False if not
"""
raw = self.__get_gpio_value(
self.dx010_psu_gpio[self.index + 1]['status'])
return int(raw, 10) == 1
def get_model(self):
"""
Retrieves the model number (or part number) of the device
Returns:
string: Model/part number of device
"""
model = self.read_fru(self.eeprom_addr, TLV_ATTR_TYPE_MODEL)
if not model:
return "N/A"
return model
def get_serial(self):
"""
Retrieves the serial number of the device
Returns:
string: Serial number of device
"""
serial = self.read_fru(self.eeprom_addr, TLV_ATTR_TYPE_SERIAL)
if not serial:
return "N/A"
return serial
def get_position_in_parent(self):
"""
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position
for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned
Returns:
integer: The 1-based relative physical position in parent device or -1 if cannot determine the position
"""
return -1
def is_replaceable(self):
"""
Indicate whether this device is replaceable.
Returns:
bool: True if it is replaceable.
"""
return True

View File

@ -23,7 +23,7 @@ THERMAL_INFO = {
"B2F_max_crit": 75,
"postion": "asic",
"name": "Front-panel temp sensor 1",
"i2c_path": "i2c-5/5-0048/hwmon/hwmon1", # u4 system-inlet
"i2c_path": "i2c-5/5-0048/hwmon", # u4 system-inlet
},
1: {
"F2B_max": 50,
@ -32,7 +32,7 @@ THERMAL_INFO = {
"B2F_max_crit": 75,
"postion": "asic",
"name": "Front-panel temp sensor 2",
"i2c_path": "i2c-6/6-0049/hwmon/hwmon2", # u2 system-inlet
"i2c_path": "i2c-6/6-0049/hwmon", # u2 system-inlet
},
2: {
"F2B_max": 70,
@ -41,7 +41,7 @@ THERMAL_INFO = {
"B2F_max_crit": 65,
"postion": "asic",
"name": "ASIC temp sensor",
"i2c_path": "i2c-7/7-004a/hwmon/hwmon3", # u44 bmc56960-on-board
"i2c_path": "i2c-7/7-004a/hwmon", # u44 bmc56960-on-board
},
3: {
"F2B_max": 70,
@ -50,7 +50,7 @@ THERMAL_INFO = {
"B2F_max_crit": 75,
"postion": "cpu",
"name": "Rear-panel temp sensor 1",
"i2c_path": "i2c-14/14-0048/hwmon/hwmon4", # u9200 cpu-on-board
"i2c_path": "i2c-14/14-0048/hwmon", # u9200 cpu-on-board
},
4: {
"F2B_max": 70,
@ -59,7 +59,7 @@ THERMAL_INFO = {
"B2F_max_crit": 75,
"postion": "cpu",
"name": "Rear-panel temp sensor 2",
"i2c_path": "i2c-15/15-004e/hwmon/hwmon5" # u9201 system-outlet
"i2c_path": "i2c-15/15-004e/hwmon" # u9201 system-outlet
}
}
NULL_VAL = "N/A"
@ -77,17 +77,38 @@ class Thermal(ThermalBase):
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._i2c_hwmon_path = "{}/{}".format(
I2C_ADAPTER_PATH, self._thermal_info["i2c_path"])
self._hwmon_path = os.path.join(
self._i2c_hwmon_path, self.__get_hwmon_name(self._i2c_hwmon_path))
self.name = self.get_name()
self.postion = self._thermal_info["postion"]
self.ss_index = 1
self.minimum_thermal = self.get_temperature()
self.maximum_thermal = self.get_temperature()
def __get_hwmon_name(self, path):
return os.listdir(path)[0]
def __get_temp(self, temp_file):
temp_file_path = os.path.join(self._hwmon_path, temp_file)
raw_temp = self._api_helper.read_txt_file(temp_file_path)
temp = float(raw_temp)/1000
return float("{:.3f}".format(temp))
def __get_threshold(self, file_name):
temp_file_path = os.path.join(self._hwmon_path, file_name)
data = self._api_helper.read_txt_file(temp_file_path)
if data:
try:
threshold = float(data)
return round(threshold/1000, 3)
except Exception:
pass
return None
def __set_threshold(self, file_name, temperature):
temp_file_path = os.path.join(self._hwmon_path, file_name)
try:
@ -114,9 +135,10 @@ class Thermal(ThermalBase):
A float number, the high threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
temp_file = "temp{}_max".format(self.ss_index)
temp = float(self.__get_temp(temp_file))
return temp
max_crit_key = '{}_max'.format(self._airflow)
high_threshold_file = "temp{}_max".format(self.ss_index)
return self.__get_threshold(high_threshold_file) or self._thermal_info.get(max_crit_key, None)
def get_low_threshold(self):
"""
@ -194,6 +216,34 @@ class Thermal(ThermalBase):
"""
return 0.001
def get_minimum_recorded(self):
"""
Retrieves the minimum recorded temperature of thermal
Returns:
A float number, the minimum recorded temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
tmp = self.get_temperature()
if tmp < self.minimum_thermal:
self.minimum_thermal = tmp
return self.minimum_thermal
def get_maximum_recorded(self):
"""
Retrieves the maximum recorded temperature of thermal
Returns:
A float number, the maximum recorded temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
tmp = self.get_temperature()
if tmp > self.maximum_thermal:
self.maximum_thermal = tmp
return self.maximum_thermal
##############################################################
###################### Device methods ########################
##############################################################
def get_name(self):
"""
Retrieves the name of the thermal device