Add get_name to pass pytest
This commit is contained in:
parent
e5cedd9be8
commit
cdad806f09
@ -6,6 +6,9 @@ try:
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
FAN_NAME_LIST = ["FAN-1F", "FAN-1R", "FAN-2F", "FAN-2R",
|
||||
"FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R",
|
||||
"FAN-5F", "FAN-5R", "FAN-6F", "FAN-6R"]
|
||||
|
||||
class Fan(PddfFan):
|
||||
"""PDDF Platform-Specific Fan class"""
|
||||
@ -15,5 +18,16 @@ class Fan(PddfFan):
|
||||
PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
# Since AS4630 psu_fan airflow direction cant be read from sysfs, it is fixed as 'F2B' or 'intake'
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the device
|
||||
Returns:
|
||||
string: The name of the device
|
||||
"""
|
||||
fan_name = FAN_NAME_LIST[(self.fantray_index-1)*2 + self.fan_index-1] \
|
||||
if not self.is_psu_fan \
|
||||
else "PSU-{} FAN-{}".format(self.fans_psu_index, self.fan_index)
|
||||
|
||||
return fan_name
|
||||
|
||||
|
@ -15,3 +15,11 @@ class FanDrawer(PddfFanDrawer):
|
||||
PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the fan drawer name
|
||||
Returns:
|
||||
string: The name of the device
|
||||
"""
|
||||
return "FanTray{}".format(self.fantray_index)
|
||||
|
||||
|
@ -17,6 +17,27 @@ class Psu(PddfPsu):
|
||||
PddfPsu.__init__(self, index, pddf_data, pddf_plugin_data)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
def get_voltage_high_threshold(self):
|
||||
"""
|
||||
Retrieves the high threshold PSU voltage output
|
||||
Returns:
|
||||
A float number, the high threshold output voltage in volts,
|
||||
e.g. 12.1
|
||||
"""
|
||||
return 14.72
|
||||
|
||||
def get_voltage_low_threshold(self):
|
||||
"""
|
||||
Retrieves the low threshold PSU voltage output
|
||||
Returns:
|
||||
A float number, the low threshold output voltage in volts,
|
||||
e.g. 12.1
|
||||
"""
|
||||
return 7.68
|
||||
|
||||
def get_name(self):
|
||||
return "PSU-{}".format(self.psu_index)
|
||||
|
||||
def get_maximum_supplied_power(self):
|
||||
"""
|
||||
Retrieves the maximum supplied power by PSU (or PSU capacity)
|
||||
|
@ -1,7 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import natsort
|
||||
from sonic_platform_pddf_base.pddf_sfp import PddfSfp
|
||||
from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper
|
||||
from sonic_py_common import device_info
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
@ -15,3 +18,23 @@ class Sfp(PddfSfp):
|
||||
PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
def __get_path_to_port_config_file(self):
|
||||
platform, hwsku = device_info.get_platform_and_hwsku()
|
||||
hwsku_path = "/".join(["/usr/share/sonic/platform",hwsku])
|
||||
return "/".join([hwsku_path, "port_config.ini"])
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the device
|
||||
Returns:
|
||||
string: The name of the device
|
||||
"""
|
||||
sfputil_helper = SfpUtilHelper()
|
||||
sfputil_helper.read_porttab_mappings(
|
||||
self.__get_path_to_port_config_file())
|
||||
|
||||
logical_port_list = sfputil_helper.logical
|
||||
logical_port_list = natsort.natsorted(logical_port_list)
|
||||
name = logical_port_list[self.port_index-1] or "Unknown"
|
||||
|
||||
return name
|
||||
|
@ -15,6 +15,12 @@ class Thermal(PddfThermal):
|
||||
PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
def get_name(self):
|
||||
if self.is_psu_thermal:
|
||||
return "PSU-{0} temp sensor 1".format(self.thermals_psu_index)
|
||||
else:
|
||||
return "Temp sensor {0}".format(self.thermal_index)
|
||||
|
||||
def get_status(self):
|
||||
get_temp=self.get_temperature()
|
||||
|
||||
|
Reference in New Issue
Block a user