Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/sonic-config-engine/sonic_device_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,24 @@ def get_system_mac():
if valid_mac_address(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:
get_mac_cmd = "ip link show eth0 | grep ether | awk '{print $2}'"

proc = subprocess.Popen(get_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(mac, err) = proc.communicate()
if err:
return None

mac = mac.strip()
hw_mac_entry_cmds = [ "ip link show eth0 | grep ether | awk '{print $2}'" ]

for get_mac_cmd in hw_mac_entry_cmds:
proc = subprocess.Popen(get_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(mac, err) = proc.communicate()
if err:
continue
mac = mac.strip()
if valid_mac_address(mac):
break

if not valid_mac_address(mac):
return None
Expand Down