Skip to content

Commit

Permalink
[mellanox]: Fix sysfs path for PSU devices in psuutil plugin (#2143)
Browse files Browse the repository at this point in the history
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 <kevinw@mellanox.com>
  • Loading branch information
kevinwangsk authored and lguohan committed Oct 12, 2018
1 parent 5ab66b1 commit cd1167d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 17 deletions.
12 changes: 8 additions & 4 deletions device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ class PsuUtil(PsuBase):

def __init__(self):
PsuBase.__init__(self)

self.psu_path = "/bsp/module/"
self.psu_presence = "psu{}_pwr_status"
self.psu_oper_status = "psu{}_pwr_status"
self.psu_path = ""
for index in range(0, 100):
hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index)
if os.path.exists(hwmon_path):
self.psu_path = hwmon_path
break
self.psu_presence = "pwr{}"
self.psu_oper_status = "pwr{}"

def get_num_psus(self):
"""
Expand Down
11 changes: 8 additions & 3 deletions device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ class PsuUtil(PsuBase):
def __init__(self):
PsuBase.__init__(self)

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

def get_num_psus(self):
"""
Expand Down
11 changes: 8 additions & 3 deletions device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ class PsuUtil(PsuBase):
def __init__(self):
PsuBase.__init__(self)

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

def get_num_psus(self):
"""
Expand Down
11 changes: 8 additions & 3 deletions device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ class PsuUtil(PsuBase):
def __init__(self):
PsuBase.__init__(self)

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

def get_num_psus(self):
"""
Expand Down
12 changes: 8 additions & 4 deletions device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ class PsuUtil(PsuBase):

def __init__(self):
PsuBase.__init__(self)

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

def get_num_psus(self):
"""
Expand Down

0 comments on commit cd1167d

Please sign in to comment.