From dbb6373e859c52aa885dee4e4ffb79b4bb8afd67 Mon Sep 17 00:00:00 2001 From: carl-nokia <63672637+carl-nokia@users.noreply.github.com> Date: Wed, 11 Nov 2020 18:11:00 -0500 Subject: [PATCH] [Marvell] Utilize eeprom for system mac and remove dependency on get_hwsku (#5882) Utilize eeprom for system mac and remove dependency on get_hwsku Co-authored-by: Carl Keene --- src/sonic-py-common/sonic_py_common/device_info.py | 11 ++++++++--- 1 file changed, 8 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 d25ccb7c13..ef4b5453b4 100644 --- a/src/sonic-py-common/sonic_py_common/device_info.py +++ b/src/sonic-py-common/sonic_py_common/device_info.py @@ -391,9 +391,14 @@ def get_system_mac(namespace=None): elif (version_info['asic_type'] == 'marvell'): # Try valid mac in eeprom, else fetch it from eth0 platform = get_platform() - hwsku = get_hwsku() - profile_cmd = 'cat' + HOST_DEVICE_PATH + '/' + platform +'/'+ hwsku +'/profile.ini | grep switchMacAddress | cut -f2 -d=' - hw_mac_entry_cmds = [ profile_cmd, "sudo decode-syseeprom -m", "ip link show eth0 | grep ether | awk '{print $2}'" ] + machine_key = "onie_machine" + machine_vars = get_machine_info() + if machine_vars is not None and machine_key in machine_vars: + hwsku = machine_vars[machine_key] + profile_cmd = 'cat' + HOST_DEVICE_PATH + '/' + platform + '/' + hwsku + '/profile.ini | grep switchMacAddress | cut -f2 -d=' + else: + profile_cmd = "false" + hw_mac_entry_cmds = ["sudo decode-syseeprom -m", profile_cmd, "ip link show eth0 | grep ether | awk '{print $2}'"] else: mac_address_cmd = "cat /sys/class/net/eth0/address" if namespace is not None: