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

[Mellanox] Enhancement for support PSU LED management #12

Closed
wants to merge 2 commits into from
Closed
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
61 changes: 61 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def __init__(self, psu_index, sku):
self.psu_current = None
self.psu_power = None
self.psu_presence = None
self.psu_temp = None
self.psu_temp_threshold = None
else:
self.always_presence = False
psu_voltage = filemap[PSU_VOLTAGE].format(self.index)
Expand All @@ -99,6 +101,9 @@ def __init__(self, psu_index, sku):
psu_presence = os.path.join(self.psu_path, psu_presence)
self.psu_presence = psu_presence

self.psu_temp = os.path.join(self.psu_path, 'thermal/psu{}_temp'.format(self.index))
self.psu_temp_threshold = os.path.join(self.psu_path, 'thermal/psu{}_temp_max'.format(self.index))

# unplugable PSU has no FAN
if sku not in hwsku_dict_with_unplugable_psu:
fan = Fan(False, psu_index, psu_index, True)
Expand Down Expand Up @@ -307,3 +312,59 @@ def get_power_available_status(self):
else:
return True, ""

def get_temperature(self):
"""
Retrieves current temperature reading from PSU

Returns:
A float number of current temperature in Celsius up to nearest thousandth
of one degree Celsius, e.g. 30.125
"""
if self.psu_temp is not None and self.get_powergood_status():
try:
temp = self._read_generic_file(self.psu_temp, 0)
return float(temp) / 1000
except Exception as e:
logger.log_info("Fail to get temperature for PSU {} due to - {}".format(self._name, repr(e)))

return None

def get_temperature_high_threshold(self):
"""
Retrieves the high threshold temperature of PSU

Returns:
A float number, the high threshold temperature of PSU in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if self.psu_temp_threshold is not None and self.get_powergood_status():
try:
temp_threshold = self._read_generic_file(self.psu_temp_threshold, 0)
return float(temp_threshold) / 1000
except Exception as e:
logger.log_info("Fail to get temperature threshold for PSU {} due to - {}".format(self._name, repr(e)))

return None

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
"""
# hw-management doesn't expose those sysfs for now
raise NotImplementedError

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
"""
# hw-management doesn't expose those sysfs for now
raise NotImplementedError