From 27fe654388aec3a610f71cf04a9623126b1cdc7c Mon Sep 17 00:00:00 2001 From: Neetha John Date: Tue, 15 Jun 2021 15:02:16 -0700 Subject: [PATCH] Add support to parse bandwidth for DeviceMgmtLinks (#7883) Add support to parse bandwidth for DeviceMgmtLinks --- src/sonic-config-engine/minigraph.py | 12 +++++-- .../tests/sample_output/ports.json | 7 +++++ .../tests/simple-sample-graph.xml | 31 +++++++++++++++++++ src/sonic-config-engine/tests/test_cfggen.py | 2 +- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 02bf6483d3..ea750426c6 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -119,7 +119,7 @@ def parse_png(png, hname): } continue - if linktype != "DeviceInterfaceLink" and linktype != "UnderlayInterfaceLink": + if linktype != "DeviceInterfaceLink" and linktype != "UnderlayInterfaceLink" and linktype != "DeviceMgmtLink": continue enddevice = link.find(str(QName(ns, "EndDevice"))).text @@ -131,13 +131,15 @@ def parse_png(png, hname): if enddevice.lower() == hname.lower(): if port_alias_map.has_key(endport): 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 port_alias_map.has_key(startport): 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 @@ -1066,6 +1068,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None): print >> sys.stderr, "Warning: ignore interface '%s' as it is not in the port_config.ini" % port_name 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 ports.items(): diff --git a/src/sonic-config-engine/tests/sample_output/ports.json b/src/sonic-config-engine/tests/sample_output/ports.json index 0e174972fb..4b36790c7c 100644 --- a/src/sonic-config-engine/tests/sample_output/ports.json +++ b/src/sonic-config-engine/tests/sample_output/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/simple-sample-graph.xml b/src/sonic-config-engine/tests/simple-sample-graph.xml index d9cf5d7959..914b37e470 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph.xml @@ -267,6 +267,25 @@ Ethernet1/33 true + + DeviceMgmtLink + 1000 + switch-t0 + fortyGigE0/16 + true + ChassisMTS1 + mgmt0 + true + + + DeviceMgmtLink + 1000 + switch-t0 + Management1 + switch-m0 + Management1 + true + @@ -369,6 +388,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 0fffab2ed0..792e3a238b 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -478,7 +478,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'}, "