From 1cd232483ff5eee1bff09f517b60878505144829 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Fri, 12 Oct 2018 17:14:43 +0800 Subject: [PATCH] [mellanox]: Fix sysfs path for PSU devices in psuutil plugin 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 --- .../x86_64-mlnx_msn2010-r0/plugins/psuutil.py | 12 ++++++++---- .../x86_64-mlnx_msn2100-r0/plugins/psuutil.py | 11 ++++++++--- .../x86_64-mlnx_msn2410-r0/plugins/psuutil.py | 11 ++++++++--- .../x86_64-mlnx_msn2700-r0/plugins/psuutil.py | 11 ++++++++--- .../x86_64-mlnx_msn2740-r0/plugins/psuutil.py | 12 ++++++++---- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py index d89a046940d0..914ef050d2c7 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py @@ -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): """ diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py index 01954dededf7..b9bb580d7c57 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py @@ -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): """ diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py index 13738bb77f46..954045dde59c 100644 --- a/device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py @@ -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): """ diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py index 13738bb77f46..954045dde59c 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py @@ -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): """ diff --git a/device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py index 13738bb77f46..8c47a0083249 100644 --- a/device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py @@ -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): """