From 4caa8876425eb381c360a4348347d25c81ff191a Mon Sep 17 00:00:00 2001 From: Eric Zhu <79439153+cel-eric@users.noreply.github.com> Date: Tue, 22 Mar 2022 00:25:36 +0800 Subject: [PATCH] Fix issue of partially parsing syseeprom value (#10020) (#10276) Why I did it The current code assumes that the value part does not have whitespace. So everything after the whitespace will be ignored. The syseeprom values returned from platform API do not match the output of "show platform syseeprom" on dx010 and e1031 device. How I did it This change improved the regular expression for parsing syseeprom values to accommodate whitespaces in the value. PR 10021 provides the solution, but committed to the wrong place for dx010 and e1031. How to verify it Compile the sonic_platform wheel for dx010, then upload to device and install the wheel, verify the platform eeprom API. Signed-off-by: Eric Zhu --- device/celestica/x86_64-cel_e1031-r0/sonic_platform/eeprom.py | 2 +- .../celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/eeprom.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/eeprom.py index dc43a4d7dd..48643b4030 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/eeprom.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/eeprom.py @@ -45,7 +45,7 @@ class Tlv(eeprom_tlvinfo.TlvInfoDecoder): for line in lines: try: match = re.search( - '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line) + '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)(.*$)', line) if match is not None: idx = match.group(1) value = match.group(3).rstrip('\0') diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py index b0d37d57be..bfde69c8d2 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/eeprom.py @@ -44,7 +44,7 @@ class Tlv(eeprom_tlvinfo.TlvInfoDecoder): for line in lines: try: match = re.search( - '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line) + '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)(.*$)', line) if match is not None: idx = match.group(1) value = match.group(3).rstrip('\0')