DellEMC: Platform2.0 API enhancements in DellEMC S6000 and other API changes (#3956)
This commit is contained in:
parent
e3475b81d7
commit
d2dadc976b
@ -43,6 +43,7 @@ class Chassis(ChassisBase):
|
||||
reset_reason_dict[0x6] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE
|
||||
|
||||
def __init__(self):
|
||||
ChassisBase.__init__(self)
|
||||
# Initialize SFP list
|
||||
self.PORT_START = 0
|
||||
self.PORT_END = 31
|
||||
|
@ -150,6 +150,10 @@ class Eeprom(TlvInfoDecoder):
|
||||
except:
|
||||
self.serial_number = 'NA'
|
||||
self.part_number = 'NA'
|
||||
if self.is_psu_eeprom:
|
||||
self.psu_type = 'NA'
|
||||
else:
|
||||
self.fan_type = 'NA'
|
||||
else:
|
||||
(valid, data) = self._get_eeprom_field("PPID")
|
||||
if valid:
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
try:
|
||||
import os
|
||||
import glob
|
||||
from sonic_platform_base.fan_base import FanBase
|
||||
from sonic_platform.eeprom import Eeprom
|
||||
except ImportError as e:
|
||||
@ -29,6 +30,7 @@ class Fan(FanBase):
|
||||
|
||||
def __init__(self, fan_index, psu_fan=False, dependency=None):
|
||||
self.is_psu_fan = psu_fan
|
||||
self.is_driver_initialized = True
|
||||
|
||||
if not self.is_psu_fan:
|
||||
# Fan is 1-based in DellEMC platforms
|
||||
@ -45,10 +47,18 @@ class Fan(FanBase):
|
||||
else:
|
||||
self.index = fan_index
|
||||
self.dependency = dependency
|
||||
self.get_fan_speed_reg = self.I2C_DIR +\
|
||||
"i2c-1/1-005{}/fan1_target".format(10 - self.index)
|
||||
self.set_fan_speed_reg = self.I2C_DIR +\
|
||||
"i2c-1/1-005{}/fan1_target".format(10 - self.index)
|
||||
|
||||
hwmon_dir = self.I2C_DIR +\
|
||||
"i2c-1/1-005{}/hwmon/".format(10 - self.index)
|
||||
try:
|
||||
hwmon_node = os.listdir(hwmon_dir)[0]
|
||||
except OSError:
|
||||
hwmon_node = "hwmon*"
|
||||
self.is_driver_initialized = False
|
||||
|
||||
self.get_fan_speed_reg = hwmon_dir + hwmon_node + '/fan1_input'
|
||||
self.max_fan_speed = MAX_S6000_PSU_FAN_SPEED
|
||||
|
||||
def _get_cpld_register(self, reg_name):
|
||||
@ -93,6 +103,14 @@ class Fan(FanBase):
|
||||
# reg_name and on failure returns 'ERR'
|
||||
rv = 'ERR'
|
||||
|
||||
if not self.is_driver_initialized:
|
||||
reg_file_path = glob.glob(reg_file)
|
||||
if len(reg_file_path):
|
||||
reg_file = reg_file_path[0]
|
||||
self._get_sysfs_path()
|
||||
else:
|
||||
return rv
|
||||
|
||||
if (not os.path.isfile(reg_file)):
|
||||
return rv
|
||||
|
||||
@ -122,6 +140,13 @@ class Fan(FanBase):
|
||||
|
||||
return rv
|
||||
|
||||
def _get_sysfs_path(self):
|
||||
fan_speed_reg = glob.glob(self.get_fan_speed_reg)
|
||||
|
||||
if len(fan_speed_reg):
|
||||
self.get_fan_speed_reg = fan_speed_reg[0]
|
||||
self.is_driver_initialized = True
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the Fan
|
||||
@ -200,16 +225,21 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
A string, either FAN_DIRECTION_INTAKE or
|
||||
FAN_DIRECTION_EXHAUST depending on fan direction
|
||||
|
||||
Notes:
|
||||
In DellEMC platforms,
|
||||
- Forward/Exhaust : Air flows from Port side to Fan side.
|
||||
- Reverse/Intake : Air flows from Fan side to Port side.
|
||||
"""
|
||||
if self.is_psu_fan:
|
||||
direction = {1: 'FAN_DIRECTION_EXHAUST', 2: 'FAN_DIRECTION_INTAKE',
|
||||
3: 'FAN_DIRECTION_EXHAUST', 4: 'FAN_DIRECTION_INTAKE'}
|
||||
direction = {1: self.FAN_DIRECTION_EXHAUST, 2: self.FAN_DIRECTION_INTAKE,
|
||||
3: self.FAN_DIRECTION_EXHAUST, 4: self.FAN_DIRECTION_INTAKE}
|
||||
fan_direction = self.dependency.eeprom.airflow_fan_type()
|
||||
else:
|
||||
direction = {1: 'FAN_DIRECTION_EXHAUST', 2: 'FAN_DIRECTION_INTAKE'}
|
||||
direction = {1: self.FAN_DIRECTION_EXHAUST, 2: self.FAN_DIRECTION_INTAKE}
|
||||
fan_direction = self.eeprom.airflow_fan_type()
|
||||
|
||||
return direction.get(fan_direction,'NA')
|
||||
return direction.get(fan_direction, self.FAN_DIRECTION_NOT_APPLICABLE)
|
||||
|
||||
def get_speed(self):
|
||||
"""
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
try:
|
||||
import os
|
||||
import glob
|
||||
from sonic_platform_base.psu_base import PsuBase
|
||||
from sonic_platform.eeprom import Eeprom
|
||||
from sonic_platform.fan import Fan
|
||||
@ -29,12 +30,20 @@ class Psu(PsuBase):
|
||||
self.index = psu_index + 1
|
||||
self.psu_presence_reg = "psu{}_prs".format(psu_index)
|
||||
self.psu_status_reg = "powersupply_status"
|
||||
self.is_driver_initialized = False
|
||||
|
||||
if self.index == 1:
|
||||
ltc_dir = self.I2C_DIR + "i2c-11/11-0042/hwmon/"
|
||||
else:
|
||||
ltc_dir = self.I2C_DIR + "i2c-11/11-0040/hwmon/"
|
||||
hwmon_node = os.listdir(ltc_dir)[0]
|
||||
|
||||
try:
|
||||
hwmon_node = os.listdir(ltc_dir)[0]
|
||||
except OSError:
|
||||
hwmon_node = "hwmon*"
|
||||
else:
|
||||
self.is_driver_initialized = True
|
||||
|
||||
self.HWMON_DIR = ltc_dir + hwmon_node + '/'
|
||||
|
||||
self.psu_voltage_reg = self.HWMON_DIR + "in1_input"
|
||||
@ -73,6 +82,14 @@ class Psu(PsuBase):
|
||||
# reg_name and on failure returns 'ERR'
|
||||
rv = 'ERR'
|
||||
|
||||
if not self.is_driver_initialized:
|
||||
reg_file_path = glob.glob(reg_file)
|
||||
if len(reg_file_path):
|
||||
reg_file = reg_file_path[0]
|
||||
self._get_sysfs_path()
|
||||
else:
|
||||
return rv
|
||||
|
||||
if (not os.path.isfile(reg_file)):
|
||||
return rv
|
||||
|
||||
@ -86,6 +103,17 @@ class Psu(PsuBase):
|
||||
rv = rv.lstrip(" ")
|
||||
return rv
|
||||
|
||||
def _get_sysfs_path(self):
|
||||
voltage_reg = glob.glob(self.psu_voltage_reg)
|
||||
current_reg = glob.glob(self.psu_current_reg)
|
||||
power_reg = glob.glob(self.psu_power_reg)
|
||||
|
||||
if len(voltage_reg) and len(current_reg) and len(power_reg):
|
||||
self.psu_voltage_reg = voltage_reg_path[0]
|
||||
self.psu_current_reg = current_reg_path[0]
|
||||
self.psu_power_reg = power_reg_path[0]
|
||||
self.is_driver_initialized = True
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the device
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
try:
|
||||
import os
|
||||
import glob
|
||||
from sonic_platform_base.thermal_base import ThermalBase
|
||||
from sonic_platform.psu import Psu
|
||||
except ImportError as e:
|
||||
@ -36,13 +37,19 @@ class Thermal(ThermalBase):
|
||||
def __init__(self, thermal_index):
|
||||
self.index = thermal_index + 1
|
||||
self.is_psu_thermal = False
|
||||
self.is_driver_initialized = True
|
||||
self.dependency = None
|
||||
|
||||
if self.index < 9:
|
||||
i2c_path = self.I2C_DIR + self.I2C_DEV_MAPPING[self.index - 1][0]
|
||||
hwmon_temp_index = self.I2C_DEV_MAPPING[self.index - 1][1]
|
||||
hwmon_temp_suffix = "max"
|
||||
hwmon_node = os.listdir(i2c_path)[0]
|
||||
try:
|
||||
hwmon_node = os.listdir(i2c_path)[0]
|
||||
except OSError:
|
||||
hwmon_node = "hwmon*"
|
||||
self.is_driver_initialized = False
|
||||
|
||||
self.HWMON_DIR = i2c_path + hwmon_node + '/'
|
||||
|
||||
if self.index == 4:
|
||||
@ -55,7 +62,12 @@ class Thermal(ThermalBase):
|
||||
dev_path = "/sys/devices/platform/coretemp.0/hwmon/"
|
||||
hwmon_temp_index = self.index - 7
|
||||
hwmon_temp_suffix = "crit"
|
||||
hwmon_node = os.listdir(dev_path)[0]
|
||||
try:
|
||||
hwmon_node = os.listdir(dev_path)[0]
|
||||
except OSError:
|
||||
hwmon_node = "hwmon*"
|
||||
self.is_driver_initialized = False
|
||||
|
||||
self.HWMON_DIR = dev_path + hwmon_node + '/'
|
||||
|
||||
self.thermal_temperature_file = self.HWMON_DIR \
|
||||
@ -70,6 +82,14 @@ class Thermal(ThermalBase):
|
||||
# sysfs_file and on failure returns 'ERR'
|
||||
rv = 'ERR'
|
||||
|
||||
if not self.is_driver_initialized:
|
||||
sysfs_file_path = glob.glob(sysfs_file)
|
||||
if len(sysfs_file_path):
|
||||
sysfs_file = sysfs_file_path[0]
|
||||
self._get_sysfs_path()
|
||||
else:
|
||||
return rv
|
||||
|
||||
if (not os.path.isfile(sysfs_file)):
|
||||
return rv
|
||||
|
||||
@ -83,6 +103,19 @@ class Thermal(ThermalBase):
|
||||
rv = rv.lstrip(" ")
|
||||
return rv
|
||||
|
||||
def _get_sysfs_path(self):
|
||||
temperature_path = glob.glob(self.thermal_temperature_file)
|
||||
high_threshold_path = glob.glob(self.thermal_high_threshold_file)
|
||||
low_threshold_path = glob.glob(self.thermal_low_threshold_file)
|
||||
|
||||
if len(temperature_path) and len(high_threshold_path):
|
||||
self.thermal_temperature_file = temperature_path[0]
|
||||
self.thermal_high_threshold_file = high_threshold_path[0]
|
||||
if len(low_threshold_path):
|
||||
self.thermal_low_threshold_file = low_threshold_path
|
||||
|
||||
self.is_driver_initialized = True
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the thermal
|
||||
|
@ -146,7 +146,7 @@ class Fan(FanBase):
|
||||
fantray_status = self._get_pmc_register(self.get_fan_speed_reg)
|
||||
if (fantray_status != 'ERR'):
|
||||
fantray_status = int(fantray_status, 10)
|
||||
if (fantray_status > 5000):
|
||||
if (fantray_status > 1000):
|
||||
status = True
|
||||
else:
|
||||
fantray_status = self._get_pmc_register(self.fan_status_reg)
|
||||
@ -163,13 +163,18 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST
|
||||
depending on fan direction
|
||||
|
||||
Notes:
|
||||
In DellEMC platforms,
|
||||
- Forward/Exhaust : Air flows from Port side to Fan side.
|
||||
- Reverse/Intake : Air flows from Fan side to Port side.
|
||||
"""
|
||||
direction = ['FAN_DIRECTION_INTAKE', 'FAN_DIRECTION_EXHAUST']
|
||||
direction = [self.FAN_DIRECTION_INTAKE, self.FAN_DIRECTION_EXHAUST]
|
||||
fan_direction = self._get_pmc_register(self.get_fan_dir_reg)
|
||||
if (fan_direction != 'ERR') and self.get_presence():
|
||||
fan_direction = int(fan_direction, 10)
|
||||
else:
|
||||
return 'N/A'
|
||||
return self.FAN_DIRECTION_NOT_APPLICABLE
|
||||
return direction[fan_direction]
|
||||
|
||||
def get_speed(self):
|
||||
|
@ -73,6 +73,7 @@ class Chassis(ChassisBase):
|
||||
power_reason_dict[44] = ChassisBase.REBOOT_CAUSE_INSUFFICIENT_FAN_SPEED
|
||||
|
||||
def __init__(self):
|
||||
ChassisBase.__init__(self)
|
||||
PORT_START = 0
|
||||
PORT_END = 31
|
||||
PORTS_IN_BLOCK = (PORT_END + 1)
|
||||
@ -92,7 +93,6 @@ class Chassis(ChassisBase):
|
||||
self.PORT_I2C_MAPPING[index][1])
|
||||
self._sfp_list.append(sfp_node)
|
||||
|
||||
ChassisBase.__init__(self)
|
||||
# Initialize EEPROM
|
||||
self._eeprom = Eeprom()
|
||||
for i in range(MAX_Z9100_FANTRAY):
|
||||
|
@ -145,7 +145,7 @@ class Fan(FanBase):
|
||||
fantray_status = self._get_pmc_register(self.get_fan_speed_reg)
|
||||
if (fantray_status != 'ERR'):
|
||||
fantray_status = int(fantray_status, 10)
|
||||
if (fantray_status > 5000):
|
||||
if (fantray_status > 1000):
|
||||
status = True
|
||||
else:
|
||||
fantray_status = self._get_pmc_register(self.fan_status_reg)
|
||||
@ -162,13 +162,18 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST
|
||||
depending on fan direction
|
||||
|
||||
Notes:
|
||||
In DellEMC platforms,
|
||||
- Forward/Exhaust : Air flows from Port side to Fan side.
|
||||
- Reverse/Intake : Air flows from Fan side to Port side.
|
||||
"""
|
||||
direction = ['FAN_DIRECTION_INTAKE', 'FAN_DIRECTION_EXHAUST']
|
||||
direction = [self.FAN_DIRECTION_INTAKE, self.FAN_DIRECTION_EXHAUST]
|
||||
fan_direction = self._get_pmc_register(self.get_fan_dir_reg)
|
||||
if (fan_direction != 'ERR') and self.get_presence():
|
||||
fan_direction = int(fan_direction, 10)
|
||||
else:
|
||||
return 'N/A'
|
||||
return self.FAN_DIRECTION_NOT_APPLICABLE
|
||||
return direction[fan_direction]
|
||||
|
||||
def get_speed(self):
|
||||
|
Loading…
Reference in New Issue
Block a user