diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index dd02a501b8..11ddf165cd 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -585,11 +585,23 @@ 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, "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, 'ifname': ifname, 'advertise': advertise} + prefix = ipnh.find(str(QName(ns, "Address"))).text + ifname = [] + nexthop = [] + for nexthop_tuple in ipnh.find(str(QName(ns, "AttachTo"))).text.split(";"): + ifname.append(nexthop_tuple.split(",")[0]) + nexthop.append(nexthop_tuple.split(",")[1]) + if ipnh.find(str(QName(ns, "Advertise"))): + advertise = ipnh.find(str(QName(ns, "Advertise"))).text + else: + advertise = "false" + if '/' not in prefix: + if ":" in prefix: + prefix = prefix + "/128" + else: + prefix = prefix + "/32" + static_routes[prefix] = {'nexthop': ",".join(nexthop), 'ifname': ",".join(ifname), 'advertise': advertise} + if port_nhipv4_map and port_nhipv6_map: subnet_check_ip = list(port_nhipv4_map.values())[0] for subnet_range in ip_intfs_map: 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 6b22d30336..debefcc15d 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,11 +121,9 @@ IPNextHop - 8.0.0.1/32 -
192.168.1.2,192.168.2.2
- PortChannel40,PortChannel50 +
8.0.0.1
+ PortChannel40,192.168.1.2;PortChannel50,192.168.2.2 StaticRoute - false
@@ -213,11 +211,9 @@ IPNextHop - 8.0.0.1/32 -
192.168.1.2,192.168.2.2
- PortChannel40,PortChannel50 +
8.0.0.1
+ PortChannel40,192.168.1.2;PortChannel50,192.168.2.2 StaticRoute - false