From 0096765ebaabb531e26f49a35414d750518417e3 Mon Sep 17 00:00:00 2001 From: Blueve <672454911@qq.com> Date: Wed, 16 Jun 2021 16:07:07 +0800 Subject: [PATCH] [console][minigraph] Avoid generate config for self console port (#7817) Signed-off-by: Jing Kan jika@microsoft.com --- src/sonic-config-engine/minigraph.py | 8 ++++---- .../tests/simple-sample-graph-case.xml | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 988b1214e7..f1a54c1796 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -198,18 +198,18 @@ def parse_png(png, hname, dpg_ecmp_content = None): startport = link.find(str(QName(ns, "StartPort"))).text baudrate = link.find(str(QName(ns, "Bandwidth"))).text flowcontrol = 1 if link.find(str(QName(ns, "FlowControl"))) is not None and link.find(str(QName(ns, "FlowControl"))).text == 'true' else 0 - if enddevice.lower() == hname.lower(): + if enddevice.lower() == hname.lower() and endport.isdigit(): console_ports[endport] = { 'remote_device': startdevice, 'baud_rate': baudrate, 'flow_control': flowcontrol - } - else: + } + elif startport.isdigit(): console_ports[startport] = { 'remote_device': enddevice, 'baud_rate': baudrate, 'flow_control': flowcontrol - } + } continue if linktype == "DeviceInterfaceLink": diff --git a/src/sonic-config-engine/tests/simple-sample-graph-case.xml b/src/sonic-config-engine/tests/simple-sample-graph-case.xml index ae7bd50a6f..7717157f18 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-case.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-case.xml @@ -194,6 +194,15 @@ + + DeviceSerialLink + 9600 + switch-t0 + console + true + switch-t1 + 1 + DeviceSerialLink 9600