[minigraph]: Fix a bug of minigraph_neighbors (#485)

Signed-off-by: Shuotian Cheng <shuche@microsoft.com>
This commit is contained in:
Shuotian Cheng 2017-04-06 14:59:30 -07:00 committed by GitHub
parent eef859baf9
commit 84a8b0d1f7
2 changed files with 5 additions and 1 deletions

View File

@ -73,7 +73,7 @@ def parse_png(png, hname):
neighbors[endport] = {'name': startdevice, 'port': startport} neighbors[endport] = {'name': startdevice, 'port': startport}
else: else:
if port_alias_map.has_key(startport): if port_alias_map.has_key(startport):
endport = port_alias_map[startport] startport = port_alias_map[startport]
neighbors[startport] = {'name': enddevice, 'port': endport} neighbors[startport] = {'name': enddevice, 'port': endport}
if child.tag == str(QName(ns, "Devices")): if child.tag == str(QName(ns, "Devices")):

View File

@ -87,3 +87,7 @@ class TestCfgGen(TestCase):
output = self.run_script(argument) 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}]") 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'}}")