From 6395ac0dd252bc688a2ff6de9d2b2b1cbb59e166 Mon Sep 17 00:00:00 2001 From: Ashwin Srinivasan <93744978+assrinivasan@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:38:24 -0700 Subject: [PATCH] Strip null bytes from parsed eeprom data before writing to db (#20512) Why I did it This was failing sonic-mgmt test test_syseepromd due to a setup error on account of null bytes being parsed from the S6000 eeprom. This is due to differences in the way sonic-db-cli handles null values in the part number as parsed by the EEPROM in the 202012 image vs 202205+ image versions: How I did it Added logic to strip null bytes from parsed data before writing to database. How to verify it Run the aforementioned sonic-mgmt test before and after making the change in this PR -- note that test fails on setup without the change. See attached logs. s6000_test_syseepromd_logs.txt Flashed image with this change on an S6000 device and ran the above sonic-mgmt test: --- .../sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py index 734feb66bacc..2401f418fdc3 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py @@ -429,7 +429,7 @@ def update_eeprom_db(self, e): data = ":".join(["{:02x}".format(T) for T in e[offset:offset+f[1]]]).upper() else: data = e[offset:offset+f[1]].decode('ascii') - client.hset('EEPROM_INFO|{}'.format(f[0]), 'Value', data) + client.hset('EEPROM_INFO|{}'.format(f[0]), 'Value', data.strip('\x00')) offset += f[1] if not self._is_valid_block_checksum(e[blk_start:blk_end]):