From e588e10bacbebe37cacf7e40e961be96ac4303a8 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox Date: Mon, 18 Mar 2024 10:47:55 +0200 Subject: [PATCH] [Mellanox] Fix error log after warm reboot --- .../sonic_platform/modules_mgmt.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/modules_mgmt.py b/platform/mellanox/mlnx-platform-api/sonic_platform/modules_mgmt.py index ddc5ac599e03..27661f9108d4 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/modules_mgmt.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/modules_mgmt.py @@ -169,16 +169,19 @@ def run(self): module_fd_indep_path = SYSFS_INDEPENDENT_FD_PRESENCE.format(port) logger.log_info("system in indep mode: {} port {}".format(self.is_supported_indep_mods_system, port)) if self.is_warm_reboot: - logger.log_info("system was warm rebooted is_warm_reboot: {} trying to read control sysfs for port {}" - .format(self.is_warm_reboot, port)) - port_control_file = SYSFS_INDEPENDENT_FD_FW_CONTROL.format(port) - try: - port_control = utils.read_int_from_file(port_control_file, raise_exception=True) - self.port_control_dict[port] = port_control - logger.log_info(f"port control sysfs is {port_control} for port {port}") - except Exception as e: - logger.log_error("exception {} for port {} trying to read port control sysfs {}" - .format(e, port, port_control_file)) + if self.is_supported_indep_mods_system: + logger.log_info("system was warm rebooted is_warm_reboot: {} trying to read control sysfs for port {}" + .format(self.is_warm_reboot, port)) + port_control_file = SYSFS_INDEPENDENT_FD_FW_CONTROL.format(port) + try: + port_control = utils.read_int_from_file(port_control_file, raise_exception=True) + self.port_control_dict[port] = port_control + logger.log_info(f"port control sysfs is {port_control} for port {port}") + except Exception as e: + logger.log_error("exception {} for port {} trying to read port control sysfs {}" + .format(e, port, port_control_file)) + else: + self.port_control_dict[port] = 0 if (self.is_supported_indep_mods_system and os.path.isfile(module_fd_indep_path)) \ and not (self.is_warm_reboot and 0 == port_control): logger.log_info("system in indep mode: {} port {} reading file {}".format(self.is_supported_indep_mods_system, port, module_fd_indep_path))