[Marvell] Fix get_system_mac for system without eeprom (#15376)
Why I did it get_system_mac was returning 'None' mac for system without eeprom. get_system_mac for marvell platform checks for mac in eeprom, profile.ini(hwsku file) and eth0. Check for valid mac returned by syseeprom was incorrect. Which was resulting in bypassing mac get from profile.ini and eth0. How I did it get_system_mac already has a logic to get first valid mac. Removed null check for mac returned by eeprom. Corrected the check for profile.ini file by checking if file exist. How to verify it Executed sonic-cfggen to check valid mac address is getting configured in config_db.json with/without profile.ini. Signed-off-by: Pavan Naregundi <pnaregundi@marvell.com>
This commit is contained in:
parent
47742dfc2c
commit
30da473fd7
@ -713,19 +713,21 @@ def get_system_mac(namespace=None):
|
||||
machine_vars = get_machine_info()
|
||||
(mac, err) = run_command(syseeprom_cmd)
|
||||
hw_mac_entry_outputs.append((mac, err))
|
||||
if not mac:
|
||||
if machine_vars is not None and machine_key in machine_vars:
|
||||
hwsku = machine_vars[machine_key]
|
||||
profile_cmd0 = ['cat', HOST_DEVICE_PATH + '/' + platform + '/' + hwsku + '/profile.ini']
|
||||
if machine_vars is not None and machine_key in machine_vars:
|
||||
hwsku = machine_vars[machine_key]
|
||||
profile_file = HOST_DEVICE_PATH + '/' + platform + '/' + hwsku + '/profile.ini'
|
||||
if os.path.exists(profile_file):
|
||||
profile_cmd0 = ['cat', profile_file]
|
||||
profile_cmd1 = ['grep', 'switchMacAddress']
|
||||
profile_cmd2 = ['cut', '-f2', '-d', '=']
|
||||
(mac, err) = run_command_pipe(profile_cmd0, profile_cmd1, profile_cmd2)
|
||||
else:
|
||||
profile_cmd = ["false"]
|
||||
(mac, err) = run_command(profile_cmd)
|
||||
hw_mac_entry_outputs.append((mac, err))
|
||||
(mac, err) = run_command_pipe(iplink_cmd0, iplink_cmd1, iplink_cmd2)
|
||||
hw_mac_entry_outputs.append((mac, err))
|
||||
else:
|
||||
profile_cmd = ["false"]
|
||||
(mac, err) = run_command(profile_cmd)
|
||||
hw_mac_entry_outputs.append((mac, err))
|
||||
(mac, err) = run_command_pipe(iplink_cmd0, iplink_cmd1, iplink_cmd2)
|
||||
hw_mac_entry_outputs.append((mac, err))
|
||||
elif (version_info['asic_type'] == 'cisco-8000'):
|
||||
# Try to get valid MAC from profile.ini first, else fetch it from syseeprom or eth0
|
||||
platform = get_platform()
|
||||
|
Loading…
Reference in New Issue
Block a user