From 84a8b0d1f79488136560de3e38444a33950d8b8e Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 6 Apr 2017 14:59:30 -0700 Subject: [PATCH] [minigraph]: Fix a bug of minigraph_neighbors (#485) Signed-off-by: Shuotian Cheng --- src/sonic-config-engine/minigraph.py | 2 +- src/sonic-config-engine/tests/test_cfggen.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index db4137a44a..2b02045647 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -73,7 +73,7 @@ def parse_png(png, hname): neighbors[endport] = {'name': startdevice, 'port': startport} else: if port_alias_map.has_key(startport): - endport = port_alias_map[startport] + startport = port_alias_map[startport] neighbors[startport] = {'name': enddevice, 'port': endport} if child.tag == str(QName(ns, "Devices")): diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index eb3e355718..e4017a51f8 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -87,3 +87,7 @@ class TestCfgGen(TestCase): output = self.run_script(argument) self.assertEqual(output.strip(), "[{'subnet': IPv4Network('10.0.0.56/31'), 'peer_addr': IPv4Address('10.0.0.57'), 'addr': IPv4Address('10.0.0.56'), 'mask': IPv4Address('255.255.255.254'), 'attachto': 'PortChannel01', 'prefixlen': 31}, {'subnet': IPv6Network('fc00::70/126'), 'peer_addr': IPv6Address('fc00::72'), 'addr': IPv6Address('fc00::71'), 'mask': '126', 'attachto': 'PortChannel01', 'prefixlen': 126}]") + def test_minigraph_neighbors(self): + argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v minigraph_neighbors' + output = self.run_script(argument) + self.assertEqual(output.strip(), "{'Ethernet116': {'name': 'ARISTA02T1', 'port': 'Ethernet1/1'}, 'Ethernet124': {'name': 'ARISTA04T1', 'port': 'Ethernet1/1'}, 'Ethernet112': {'name': 'ARISTA01T1', 'port': 'Ethernet1/1'}, 'Ethernet120': {'name': 'ARISTA03T1', 'port': 'Ethernet1/1'}}")