Skip to content

Commit cd1167d

Browse files
kevinwangsklguohan
authored andcommitted
[mellanox]: Fix sysfs path for PSU devices in psuutil plugin (#2143)
Snmp container needs to access the PSU path, but /bsp doesn't mount into the container, so need to use the real path rather than a symlink. Signed-off-by: Kevin Wang <[email protected]>
1 parent 5ab66b1 commit cd1167d

File tree

5 files changed

+40
-17
lines changed

5 files changed

+40
-17
lines changed

device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ class PsuUtil(PsuBase):
2020

2121
def __init__(self):
2222
PsuBase.__init__(self)
23-
24-
self.psu_path = "/bsp/module/"
25-
self.psu_presence = "psu{}_pwr_status"
26-
self.psu_oper_status = "psu{}_pwr_status"
23+
self.psu_path = ""
24+
for index in range(0, 100):
25+
hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index)
26+
if os.path.exists(hwmon_path):
27+
self.psu_path = hwmon_path
28+
break
29+
self.psu_presence = "pwr{}"
30+
self.psu_oper_status = "pwr{}"
2731

2832
def get_num_psus(self):
2933
"""

device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ class PsuUtil(PsuBase):
2121
def __init__(self):
2222
PsuBase.__init__(self)
2323

24-
self.psu_path = "/bsp/module/"
25-
self.psu_presence = "psu{}_status"
26-
self.psu_oper_status = "psu{}_pwr_status"
24+
self.psu_path = ""
25+
for index in range(0, 100):
26+
hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index)
27+
if os.path.exists(hwmon_path):
28+
self.psu_path = hwmon_path
29+
break
30+
self.psu_presence = "pwr{}"
31+
self.psu_oper_status = "pwr{}"
2732

2833
def get_num_psus(self):
2934
"""

device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ class PsuUtil(PsuBase):
2121
def __init__(self):
2222
PsuBase.__init__(self)
2323

24-
self.psu_path = "/bsp/module/"
25-
self.psu_presence = "psu{}_status"
26-
self.psu_oper_status = "psu{}_pwr_status"
24+
self.psu_path = ""
25+
for index in range(0, 100):
26+
hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index)
27+
if os.path.exists(hwmon_path):
28+
self.psu_path = hwmon_path
29+
break
30+
self.psu_presence = "psu{}"
31+
self.psu_oper_status = "pwr{}"
2732

2833
def get_num_psus(self):
2934
"""

device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ class PsuUtil(PsuBase):
2121
def __init__(self):
2222
PsuBase.__init__(self)
2323

24-
self.psu_path = "/bsp/module/"
25-
self.psu_presence = "psu{}_status"
26-
self.psu_oper_status = "psu{}_pwr_status"
24+
self.psu_path = ""
25+
for index in range(0, 100):
26+
hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index)
27+
if os.path.exists(hwmon_path):
28+
self.psu_path = hwmon_path
29+
break
30+
self.psu_presence = "psu{}"
31+
self.psu_oper_status = "pwr{}"
2732

2833
def get_num_psus(self):
2934
"""

device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ class PsuUtil(PsuBase):
2020

2121
def __init__(self):
2222
PsuBase.__init__(self)
23-
24-
self.psu_path = "/bsp/module/"
25-
self.psu_presence = "psu{}_status"
26-
self.psu_oper_status = "psu{}_pwr_status"
23+
self.psu_path = ""
24+
for index in range(0, 100):
25+
hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index)
26+
if os.path.exists(hwmon_path):
27+
self.psu_path = hwmon_path
28+
break
29+
self.psu_presence = "psu{}"
30+
self.psu_oper_status = "pwr{}"
2731

2832
def get_num_psus(self):
2933
"""

0 commit comments

Comments
 (0)