diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 66974d45e4..4a6e0d3827 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -218,7 +218,7 @@ def parse_png(png, hname, dpg_ecmp_content = None): startdevice = link.find(str(QName(ns, "StartDevice"))).text port_device_map[endport] = startdevice - if linktype != "DeviceInterfaceLink" and linktype != "UnderlayInterfaceLink": + if linktype != "DeviceInterfaceLink" and linktype != "UnderlayInterfaceLink" and linktype != "DeviceMgmtLink": continue enddevice = link.find(str(QName(ns, "EndDevice"))).text @@ -230,13 +230,15 @@ def parse_png(png, hname, dpg_ecmp_content = None): if enddevice.lower() == hname.lower(): if endport in port_alias_map: endport = port_alias_map[endport] - neighbors[endport] = {'name': startdevice, 'port': startport} + if linktype != "DeviceMgmtLink": + neighbors[endport] = {'name': startdevice, 'port': startport} if bandwidth: port_speeds[endport] = bandwidth elif startdevice.lower() == hname.lower(): if startport in port_alias_map: startport = port_alias_map[startport] - neighbors[startport] = {'name': enddevice, 'port': endport} + if linktype != "DeviceMgmtLink": + neighbors[startport] = {'name': enddevice, 'port': endport} if bandwidth: port_speeds[startport] = bandwidth @@ -1405,6 +1407,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw print("Warning: ignore interface '%s' as it is not in the port_config.ini" % port_name, file=sys.stderr) continue + # skip management ports + if port_name in mgmt_alias_reverse_mapping.keys(): + continue + ports.setdefault(port_name, {})['speed'] = port_speed_png[port_name] for port_name, port in list(ports.items()): diff --git a/src/sonic-config-engine/tests/sample_output/py2/ports.json b/src/sonic-config-engine/tests/sample_output/py2/ports.json index 0e174972fb..4b36790c7c 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/ports.json +++ b/src/sonic-config-engine/tests/sample_output/py2/ports.json @@ -20,6 +20,13 @@ }, "OP": "SET" }, + { + "PORT_TABLE:Ethernet16": { + "speed": "1000", + "description": "fortyGigE0/16" + }, + "OP": "SET" + }, { "PORT_TABLE:Ethernet12": { "speed": "100000", diff --git a/src/sonic-config-engine/tests/sample_output/py3/ports.json b/src/sonic-config-engine/tests/sample_output/py3/ports.json index 36f5ad117c..1fee36338b 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/ports.json +++ b/src/sonic-config-engine/tests/sample_output/py3/ports.json @@ -26,5 +26,12 @@ "description": "Interface description" }, "OP": "SET" + }, + { + "PORT_TABLE:Ethernet16": { + "speed": "1000", + "description": "fortyGigE0/16" + }, + "OP": "SET" } ] diff --git a/src/sonic-config-engine/tests/simple-sample-graph.xml b/src/sonic-config-engine/tests/simple-sample-graph.xml index 662544d20f..90abd1885b 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph.xml @@ -308,6 +308,25 @@ Ethernet1/33 true + + DeviceMgmtLink + 1000 + switch-t0 + fortyGigE0/16 + true + ChassisMTS1 + mgmt0 + true + + + DeviceMgmtLink + 1000 + switch-t0 + Management1 + switch-m0 + Management1 + true + @@ -410,6 +429,18 @@ 100000 Interface description + + DeviceInterface + + true + 1 + fortyGigE0/16 + + false + 0 + 0 + 100000 + true 0 diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index 4d05952700..416f702f60 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -524,7 +524,7 @@ class TestCfgGen(TestCase): "'Ethernet4': {'lanes': '25,26,27,28', 'description': 'fortyGigE0/4', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/4', 'admin_status': 'up', 'speed': '25000'}, " "'Ethernet8': {'lanes': '37,38,39,40', 'description': 'Interface description', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/8', 'admin_status': 'up', 'speed': '1000'}, " "'Ethernet12': {'lanes': '33,34,35,36', 'fec': 'rs', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/12', 'admin_status': 'up', 'speed': '100000', 'description': 'Interface description'}, " - "'Ethernet16': {'alias': 'fortyGigE0/16', 'pfc_asym': 'off', 'lanes': '41,42,43,44', 'description': 'fortyGigE0/16', 'mtu': '9100'}, " + "'Ethernet16': {'lanes': '41,42,43,44', 'pfc_asym': 'off', 'description': 'fortyGigE0/16', 'mtu': '9100', 'alias': 'fortyGigE0/16', 'speed': '1000'}, " "'Ethernet20': {'alias': 'fortyGigE0/20', 'pfc_asym': 'off', 'lanes': '45,46,47,48', 'description': 'fortyGigE0/20', 'mtu': '9100'}, " "'Ethernet24': {'alias': 'fortyGigE0/24', 'pfc_asym': 'off', 'lanes': '5,6,7,8', 'description': 'fortyGigE0/24', 'mtu': '9100'}, " "'Ethernet28': {'alias': 'fortyGigE0/28', 'pfc_asym': 'off', 'lanes': '1,2,3,4', 'description': 'fortyGigE0/28', 'mtu': '9100'}, "