[Mellanox] Fix SN2010 issue: "show platform psustatus" returns "NOT PRESENT" for power off PSU on 201811 (#3598)
* [plugins/psuutil]Align psuutil of 2010 with that of 2100. * [plugins/psuutil.py]Address comments via using more human-readable code
This commit is contained in:
parent
5965c3f4f9
commit
3f42353bf1
@ -20,6 +20,7 @@ class PsuUtil(PsuBase):
|
||||
|
||||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
self.psu_path = ""
|
||||
for index in range(0, 100):
|
||||
hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index)
|
||||
@ -65,14 +66,7 @@ class PsuUtil(PsuBase):
|
||||
:param index: An integer, 1-based index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is plugged, False if not
|
||||
"""
|
||||
if index is None:
|
||||
if not isinstance(index, int):
|
||||
return False
|
||||
|
||||
status = 0
|
||||
try:
|
||||
with open(self.psu_path + self.psu_presence.format(index), 'r') as presence_status:
|
||||
status = int(presence_status.read())
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
return status == 1
|
||||
return index > 0 and index <= self.get_num_psus()
|
||||
|
@ -66,4 +66,7 @@ class PsuUtil(PsuBase):
|
||||
:param index: An integer, 1-based index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is plugged, False if not
|
||||
"""
|
||||
return isinstance(index, int) and index > 0 and index <= self.get_num_psus()
|
||||
if not isinstance(index, int):
|
||||
return False
|
||||
|
||||
return index > 0 and index <= self.get_num_psus()
|
||||
|
Loading…
Reference in New Issue
Block a user