Added get_system_mac support for cisco-8000 device (#9104)
Added get_system_mac support for cisco-8000 device Why I did it This is required to assign unique MACs to namespaces on Backend and Frontend asics for cisco-8000 platforms How I did it Add vendor specific hook in get_system_mac. The MAC address are read from /profile.ini file How to verify it config load_minigraph on a multi-asic system config save check mac addresses in DEVICE_METADATA section in each config_db json file
This commit is contained in:
parent
56049830fb
commit
fed19e3fb5
@ -1753,6 +1753,15 @@ def parse_asic_sub_role(filename, asic_name):
|
||||
sub_role, _, _, _ = parse_asic_meta(child, asic_name)
|
||||
return sub_role
|
||||
|
||||
def parse_asic_switch_type(filename, asic_name):
|
||||
if os.path.isfile(filename):
|
||||
root = ET.parse(filename).getroot()
|
||||
for child in root:
|
||||
if child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||
_, _, switch_type, _ = parse_asic_meta(child, asic_name)
|
||||
return switch_type
|
||||
return None
|
||||
|
||||
def parse_asic_meta_get_devices(root):
|
||||
local_devices = []
|
||||
|
||||
|
@ -29,7 +29,7 @@ import yaml
|
||||
from collections import OrderedDict
|
||||
from config_samples import generate_sample_config, get_available_config
|
||||
from functools import partial
|
||||
from minigraph import minigraph_encoder, parse_xml, parse_device_desc_xml, parse_asic_sub_role
|
||||
from minigraph import minigraph_encoder, parse_xml, parse_device_desc_xml, parse_asic_sub_role, parse_asic_switch_type
|
||||
from portconfig import get_port_config, get_breakout_mode
|
||||
from redis_bcc import RedisBytecodeCache
|
||||
from sonic_py_common.multi_asic import get_asic_id_from_name, get_asic_device_id
|
||||
@ -363,13 +363,17 @@ def main():
|
||||
|
||||
|
||||
# the minigraph file must be provided to get the mac address for backend asics
|
||||
# or switch_type chassis_packet
|
||||
if args.platform_info:
|
||||
asic_role = None
|
||||
switch_type = None
|
||||
if asic_name is not None:
|
||||
if args.minigraph is not None:
|
||||
asic_role = parse_asic_sub_role(args.minigraph, asic_name)
|
||||
switch_type = parse_asic_switch_type(args.minigraph, asic_name)
|
||||
|
||||
if asic_role is not None and asic_role.lower() == "backend":
|
||||
if ((switch_type is not None and switch_type.lower() == "chassis-packet") or
|
||||
(asic_role is not None and asic_role.lower() == "backend")):
|
||||
mac = device_info.get_system_mac(namespace=asic_name)
|
||||
else:
|
||||
mac = device_info.get_system_mac()
|
||||
|
@ -492,6 +492,14 @@ def get_system_mac(namespace=None):
|
||||
else:
|
||||
profile_cmd = "false"
|
||||
hw_mac_entry_cmds = ["sudo decode-syseeprom -m", profile_cmd, "ip link show eth0 | grep ether | awk '{print $2}'"]
|
||||
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()
|
||||
if namespace is not None:
|
||||
profile_cmd = 'cat ' + HOST_DEVICE_PATH + '/' + platform + '/profile.ini | grep ' + namespace + 'switchMacAddress | cut -f2 -d='
|
||||
else:
|
||||
profile_cmd = "false"
|
||||
hw_mac_entry_cmds = [profile_cmd, "sudo decode-syseeprom -m", "ip link show eth0 | grep ether | awk '{print $2}'"]
|
||||
else:
|
||||
mac_address_cmd = "cat /sys/class/net/eth0/address"
|
||||
if namespace is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user