[sonic-cfg] [Marvell] read system mac address from eeprom (#3309)
* [sonic-cfg] [Marvell] get_system_mac() to fetch valid mac address from Eeprom else get mac address from eth0 * [platform] Marvell mac address fetch for different platform based on board Signed-off-by: Antony Rheneus <arheneus@marvell.com>
This commit is contained in:
parent
d16ece23bb
commit
17b5fd2b5f
@ -65,16 +65,24 @@ def get_system_mac():
|
|||||||
if valid_mac_address(mac):
|
if valid_mac_address(mac):
|
||||||
return mac
|
return mac
|
||||||
|
|
||||||
get_mac_cmd = "sudo decode-syseeprom -m"
|
hw_mac_entry_cmds = [ "sudo decode-syseeprom -m" ]
|
||||||
|
elif (version_info['asic_type'] == 'marvell'):
|
||||||
|
# Try valid mac in eeprom, else fetch it from eth0
|
||||||
|
platform = get_platform_info(get_machine_info())
|
||||||
|
hwsku = get_machine_info()['onie_machine']
|
||||||
|
profile_cmd = 'cat /usr/share/sonic/device/' + platform +'/'+ hwsku +'/profile.ini | cut -f2 -d='
|
||||||
|
hw_mac_entry_cmds = [ profile_cmd, "sudo decode-syseeprom -m", "ip link show eth0 | grep ether | awk '{print $2}'" ]
|
||||||
else:
|
else:
|
||||||
get_mac_cmd = "ip link show eth0 | grep ether | awk '{print $2}'"
|
hw_mac_entry_cmds = [ "ip link show eth0 | grep ether | awk '{print $2}'" ]
|
||||||
|
|
||||||
proc = subprocess.Popen(get_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
for get_mac_cmd in hw_mac_entry_cmds:
|
||||||
(mac, err) = proc.communicate()
|
proc = subprocess.Popen(get_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if err:
|
(mac, err) = proc.communicate()
|
||||||
return None
|
if err:
|
||||||
|
continue
|
||||||
mac = mac.strip()
|
mac = mac.strip()
|
||||||
|
if valid_mac_address(mac):
|
||||||
|
break
|
||||||
|
|
||||||
if not valid_mac_address(mac):
|
if not valid_mac_address(mac):
|
||||||
return None
|
return None
|
||||||
|
Reference in New Issue
Block a user