diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index a7d3b0a833cc..14cbc6f8a470 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -510,10 +510,11 @@ def parse_dpg(dpg, hname): elif ":" in ipnhaddr: port_nhipv6_map[ipnhfmbr] = ipnhaddr elif ipnh.find(str(QName(ns, "Type"))).text == 'StaticRoute': - prefix = ipnh.find(str(QName(ns, "AttachTo"))).text + prefix = ipnh.find(str(QName(ns, "AssociatedTo"))).text + ifname = ipnh.find(str(QName(ns, "AttachTo"))).text nexthop = ipnh.find(str(QName(ns, "Address"))).text advertise = ipnh.find(str(QName(ns, "Advertise"))).text - static_routes[prefix] = {'nexthop': nexthop, 'advertise': advertise} + static_routes[prefix] = {'nexthop': nexthop, 'ifname': ifname, 'advertise': advertise} if port_nhipv4_map and port_nhipv6_map: subnet_check_ip = list(port_nhipv4_map.values())[0] diff --git a/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml b/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml index 65d435539d20..183c578385f0 100644 --- a/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml +++ b/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml @@ -121,8 +121,9 @@ IPNextHop - 8.0.0.1/32 + 8.0.0.1/32
192.168.1.2,192.168.2.2
+ PortChannel40,PortChannel50 StaticRoute false
@@ -212,8 +213,9 @@ IPNextHop - 8.0.0.1/32 -
192.168.1.2,192.168.2.2
+ 8.0.0.1/32 +
192.168.1.2,192.168.2.2
+ PortChannel40,PortChannel50 StaticRoute false
diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index cbef4bbe8e5f..bf1221cab9ee 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -904,14 +904,14 @@ def test_minigraph_bgp_packet_chassis_static_route(self): output = self.run_script(argument) self.assertEqual( utils.to_dict(output.strip()), - utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'advertise':'false'}}") + utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false'}}") ) argument = '-m "' + self.packet_chassis_graph + '" -p "' + self.packet_chassis_port_ini + '" -n "' + "asic1" + '" -v "STATIC_ROUTE"' output = self.run_script(argument) self.assertEqual( utils.to_dict(output.strip()), - utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'advertise':'false'}}") + utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false'}}") ) def test_minigraph_bgp_packet_chassis_vlan_subintf(self):