[minigraph.py]: Updated Static Route Minigraph Attribute property (#14951)

What I did:
Updated Static Route Attribute in Minigraph. NGS Minigraph has define semantics of static route differently.
See below for differences:-

Microsoft ADO: 17956325

Before

<AssociatedTo>8.0.0.1/32</AssociatedTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AttachTo>PortChannel40,PortChannel50</AttachTo>

Now:

<Address>8.0.0.1</Address>
<AttachTo>PortChannel40,192.168.1.2;PortChannel50,192.168.2.2</AttachTo>

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
This commit is contained in:
abdosi 2023-05-19 11:49:10 -07:00 committed by GitHub
parent ecb4db58a9
commit b5b5883c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 13 deletions

View File

@ -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:

View File

@ -121,11 +121,9 @@
<IPNextHop>
<ElementType>IPNextHop</ElementType>
<Name i:nil="true"/>
<AssociatedTo>8.0.0.1/32</AssociatedTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AttachTo>PortChannel40,PortChannel50</AttachTo>
<Address>8.0.0.1</Address>
<AttachTo>PortChannel40,192.168.1.2;PortChannel50,192.168.2.2</AttachTo>
<Type>StaticRoute</Type>
<Advertise>false</Advertise>
</IPNextHop>
</IPNextHops>
<DataAcls/>
@ -213,11 +211,9 @@
<IPNextHop>
<ElementType>IPNextHop</ElementType>
<Name i:nil="true"/>
<AssociatedTo>8.0.0.1/32</AssociatedTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AttachTo>PortChannel40,PortChannel50</AttachTo>
<Address>8.0.0.1</Address>
<AttachTo>PortChannel40,192.168.1.2;PortChannel50,192.168.2.2</AttachTo>
<Type>StaticRoute</Type>
<Advertise>false</Advertise>
</IPNextHop>
</IPNextHops>
</DeviceDataPlaneInfo>