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 914ef050d2c..54241282410 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py @@ -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 @@ def get_psu_presence(self, index): :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: - 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: + if not isinstance(index, int): return False - return status == 1 + return index > 0 and index <= self.get_num_psus() 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 b9bb580d7c5..54241282410 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py @@ -66,4 +66,7 @@ def get_psu_presence(self, index): :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()