From d699d32553dfa766fdf8abc84debdd9a848c6e27 Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Sun, 5 Feb 2023 02:17:56 +0800 Subject: [PATCH] [BugFix] Fix the bug that it gets error system-mac of centec platform (#12721) (#13625) --- src/sonic-py-common/sonic_py_common/device_info.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sonic-py-common/sonic_py_common/device_info.py b/src/sonic-py-common/sonic_py_common/device_info.py index 48a7e76e2f..5fc7f13c30 100644 --- a/src/sonic-py-common/sonic_py_common/device_info.py +++ b/src/sonic-py-common/sonic_py_common/device_info.py @@ -647,9 +647,10 @@ def get_system_mac(namespace=None): # Align last byte of MAC if necessary if version_info and version_info['asic_type'] == 'centec': - last_byte = mac[-2:] - aligned_last_byte = format(int(int(last_byte, 16) + 1), '02x') - mac = mac[:-2] + aligned_last_byte + mac_tmp = mac.replace(':','') + mac_tmp = "{:012x}".format(int(mac_tmp, 16) + 1) + mac_tmp = re.sub("(.{2})", "\\1:", mac_tmp, 0, re.DOTALL) + mac = mac_tmp[:-1] return mac