Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minigraph] Enhanced parser to parse interface name for static route nexthop #9707

Merged
merged 18 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@
<IPNextHop>
<ElementType>IPNextHop</ElementType>
<Name i:nil="true"/>
<AttachTo>8.0.0.1/32</AttachTo>
<AssociatedTo>8.0.0.1/32</AssociatedTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AttachTo>PortChannel40,PortChannel50</AttachTo>
<Type>StaticRoute</Type>
<Advertise>false</Advertise>
</IPNextHop>
Expand Down Expand Up @@ -212,8 +213,9 @@
<IPNextHop>
<ElementType>IPNextHop</ElementType>
<Name i:nil="true"/>
<AttachTo>8.0.0.1/32</AttachTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AssociatedTo>8.0.0.1/32</AssociatedTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AttachTo>PortChannel40,PortChannel50</AttachTo>
<Type>StaticRoute</Type>
<Advertise>false</Advertise>
</IPNextHop>
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down