From fc61ec9dbf27de17f5aaa9bb7359180d826daab7 Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Thu, 24 Jun 2021 01:41:28 +0800 Subject: [PATCH] [Mellanox] Return N/A for PSU's model, serial and revision on platforms with fixed PSU (#7927) - Why I did it The methods get_model, get_serial, and get_revision have been implemented by reading relevant information from VPD and then recording the information into relevant fields. However, there is no VPD data on platforms with fixed PSUs and relevant fields haven't been initialized, which causes the methods to throw exceptions. which in turn prevents psud from inserting fields into PSU table. Eventually, this causes show platform psustatus doesn't output correct info. - How I did it Initialize those fields as N/A on systems with fixed PSUs. - How to verify it Manually test. Signed-off-by: Stephen Sun --- platform/mellanox/mlnx-platform-api/sonic_platform/psu.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py index bae310c5d2..dbc395ba93 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py @@ -88,6 +88,10 @@ class Psu(PsuBase): self.psu_data = DEVICE_DATA[platform]['psus'] psu_vpd = filemap[PSU_VPD] + self.model = "N/A" + self.serial = "N/A" + self.rev = "N/A" + if psu_vpd is not None: self.psu_vpd = os.path.join(self.psu_path, psu_vpd.format(self.index)) self.vpd_data = self._read_vpd_file(self.psu_vpd) @@ -95,25 +99,21 @@ class Psu(PsuBase): if PN_VPD_FIELD in self.vpd_data: self.model = self.vpd_data[PN_VPD_FIELD] else: - self.model = "" logger.log_error("Fail to read PSU{} model number: No key {} in VPD {}".format(self.index, PN_VPD_FIELD, self.psu_vpd)) if SN_VPD_FIELD in self.vpd_data: self.serial = self.vpd_data[SN_VPD_FIELD] else: - self.serial = "" logger.log_error("Fail to read PSU{} serial number: No key {} in VPD {}".format(self.index, SN_VPD_FIELD, self.psu_vpd)) if REV_VPD_FIELD in self.vpd_data: self.rev = self.vpd_data[REV_VPD_FIELD] else: - self.rev = "" logger.log_error("Fail to read PSU{} serial number: No key {} in VPD {}".format(self.index, REV_VPD_FIELD, self.psu_vpd)) else: logger.log_info("Not reading PSU{} VPD data: Platform is fixed".format(self.index)) - if not self.psu_data['hot_swappable']: self.always_present = True self.psu_voltage = None