Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DellEMC: S5232F support for show system-health command #8334

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services_to_ignore": [],
"devices_to_ignore": ["fan.speed"],
"user_defined_checkers": [],
"polling_interval": 60,
"led_color": {
"fault" : "amber",
"normal" : "green",
"booting": "blinking_green"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from sonic_platform.thermal import Thermal
from sonic_platform.fan_drawer import FanDrawer
from sonic_platform.watchdog import Watchdog
import sonic_platform.hwaccess as hwaccess
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

Expand All @@ -38,6 +39,21 @@ class Chassis(ChassisBase):

oir_fd = -1
epoll = -1
pci_res = "/sys/bus/pci/devices/0000:04:00.0/resource0"
sysled_offset = 0x0024
SYSLED_COLOR_TO_REG = {
"blinking_green": 0x0,
"green" : 0x10,
"amber" : 0x20,
"blinking_amber": 0x30
}

REG_TO_SYSLED_COLOR = {
0x0 : "blinking_green",
0x10 : "green",
0x20 : "amber",
0x30 : "blinking_amber"
}

_global_port_pres_dict = {}

Expand Down Expand Up @@ -222,6 +238,40 @@ def get_num_sfps(self):
"""
return self._num_sfps

def initizalize_system_led(self):
self.sys_ledcolor = "green"

def get_status_led(self):
"""
Gets the current system LED color
Returns:
A string that represents the supported color
"""
val = hwaccess.pci_get_value(self.pci_res, self.sysled_offset)
if val != -1:
val = val & 0x30
return self.REG_TO_SYSLED_COLOR.get(val)
return self.sys_ledcolor

def set_status_led(self, color):
"""
Set system LED status based on the color type passed in the argument.
Argument: Color to be set
Returns:
bool: True is specified color is set, Otherwise return False
"""

if color not in list(self.SYSLED_COLOR_TO_REG.keys()):
return False

val = hwaccess.pci_get_value(self.pci_res, self.sysled_offset)
val = (val & 0xFFCF) | self.SYSLED_COLOR_TO_REG[color]

hwaccess.pci_set_value(self.pci_res, val, self.sysled_offset)
self.sys_ledcolor = color
return True

def get_reboot_cause(self):
"""
Retrieves the cause of the previous reboot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class Psu(PsuBase):

# { PSU-ID: { Sensor-Name: Sensor-ID } }
SENSOR_MAPPING = { 1: { "State": 0x31, "Current": 0x39,
"Power": 0x37, "Voltage": 0x38 },
"Power": 0x37, "Voltage": 0x38,
"Temperature": 0xc },
2: { "State": 0x32, "Current": 0x3F,
"Power": 0x3D, "Voltage": 0x3E } }
"Power": 0x3D, "Voltage": 0x3E,
"Temperature": 0xd } }
# ( PSU-ID: FRU-ID }
FRU_MAPPING = { 1: 1, 2: 2 }

Expand All @@ -37,6 +39,7 @@ def __init__(self, psu_index):
self.voltage_sensor = IpmiSensor(self.SENSOR_MAPPING[self.index]["Voltage"])
self.current_sensor = IpmiSensor(self.SENSOR_MAPPING[self.index]["Current"])
self.power_sensor = IpmiSensor(self.SENSOR_MAPPING[self.index]["Power"])
self.temp_sensor = IpmiSensor(self.SENSOR_MAPPING[self.index ]["Temperature"])
self.fru = IpmiFru(self.FRU_MAPPING[self.index])

self._fan_list.append(Fan(fan_index=self.index, psu_fan=True,
Expand Down Expand Up @@ -113,6 +116,56 @@ def get_voltage(self):

return float(voltage)

def get_voltage_low_threshold(self):
"""
Returns PSU low threshold in Volts
"""

is_valid, low_threshold = self.voltage_sensor.get_threshold("LowerCritical")
if not is_valid:
low_threshold = 11.6
low_threshold = "{:.2f}".format(low_threshold)

return float(low_threshold)

def get_voltage_high_threshold(self):
"""
Returns PSU high threshold in Volts
"""

is_valid, high_threshold = self.voltage_sensor.get_threshold("UpperCritical")
if not is_valid:
high_threshold = 12.8
high_threshold = "{:.2f}".format(high_threshold)

return float(high_threshold)

def get_temperature(self):
"""
Retrieves current temperature reading from thermal
Returns:
A float number of current temperature in Celsius up to
nearest thousandth of one degree Celsius, e.g. 30.125
"""
is_valid, temperature = self.temp_sensor.get_reading()
if not is_valid:
temperature = 0

return float(temperature)

def get_temperature_high_threshold(self):
"""
Returns the high temperature threshold for PSU in Celsius
"""

is_valid, high_threshold = self.temp_sensor.get_threshold("UpperCritical")
if not is_valid:
high_threshold = 105
high_threshold = "{:.2f}".format(high_threshold)

return float(high_threshold)

def get_current(self):
"""
Retrieves present electric current supplied by PSU
Expand Down