02-26-2019 03:09 AM - edited 02-26-2019 03:52 AM
Hi,
I've managed to get all the routing rules in my APIC using this REST API query:
https://<APIC IP>/api/node/class/topSystem.json?query-target=subtree&target-subtree-class=ospfDom,bgpDom,eigrpDom,ipv4Dom,isisDom,ospfv3Dom,uribv4Dom&rsp-subtree=full&rsp-subtree-class=ospfRoute,bgpRoute,eigrpRoute,ipv4Route,isisRoute,ospfv3Route,uri...
and then I filter them by the tenant and vrf.
However, I get the routing rules per domain (ospf, bgp etc.), while what I really want is getting one combined routing table per vrf, much like running the CLI command "show ip route vrf '<TENANT>:<VRF_NAME>'" on the leaf.
Is there such a query that retrieves all routing rules of the vrf altogether?
Thanks in advance,
Guy
Solved! Go to Solution.
02-27-2019 11:12 PM
Hi
Have you tried to query just the uribv4Route-MO?
https://{{IP}}/api/class/uribv4Route.json?query-target-filter=wcard(uribv4Route.dn,"<TENANT>:<VRF>")&rsp-subtree=full&order-by=uribv4Route.dn|asc
(you need to replace <TENANT> and <VRF> with the corresponding names...)
HTH
Marcel
02-26-2019 07:25 PM
Are you looking for like an API call for all the routes on every leaf? Why don't you just use "show ip route vrf all" on a per leaf basis?
You could also do this from the APIC CLI:
a-apic1# acidiag fnvread | egrep " active" | egrep "leaf|spine" | awk '{print $1}' | sed -e 'H;${x;s/\n/,/g;s/^,//;p;};d'
101,102,103,204,205,206,1001,1002,2001,2002,3101,3102,3201,3202 <-- gives you all your node IDs
Copy paste that and run the desired exam, it will run the show command on each node one by one
a-apic1# fabric 101,102,103,204,205,206,1001,1002,2001,2002,3101,3102,3201,3202 show ip route vrf all
This is a lot of information query though if you have a lot of leafs / a lot of routes / vrfs.
02-27-2019 03:09 AM
Thanks for answering.
However, I'm looking for a REST API call that would replace "show ip route vrf all" APIC cli command.
02-27-2019 02:10 AM
Hello,
You could try that API call:
https://<APIC>/api/node/mo/topology/<pod ID>/node-<ID>/sys/uribv4/dom-<TENANT>:<VRF_NAME>/db-rt.json?query-target=subtree&target-subtree-class=uribv4Nexthop
Hope this helps
Remi Astruc
02-27-2019 03:13 AM
Thanks, but this call is relevant only for uribv4 domain. The request I've posted in my question already contains this data, among the rest of the domains (ospf, bgp, static routes etc.).
The problem is that I get the data per domain, i.e. bgp routing rules table alone, ospf routing table alone, static routes table alone, while what I really want is getting all routing rules together in one table, the same as I get when I run "show ip route vrf" on the APIC CLI.
02-27-2019 03:28 AM
Hello,
That API call I provided gets precisely the list of all the routes with next hop info for a given VRF, no matter if the routes come from BGP, OSPF, or other.
Have you tried to run it, and actually compare to your show ip route vrf? If so please explain the exact differences you see.
Or maybe you meant something else with "How to get all routing rules"?
03-03-2019 12:48 AM
I did try to run it but on Cisco LAB, and didn't get the static routes configured.
However, it also seems like APIC CLI is not available in Cisco LAB.
We'll run in a real env and update soon.
10x!
03-04-2019 12:35 AM - edited 03-05-2019 09:18 AM
Indeed, it helped us get to the right answer :)
I used the following (per <TENANT:VRF>):
https://<APIC IP>/api/node/class/uribv4Dom.json?rsp-subtree=full&rsp-subtree-class=uribv4Route&query-target-filter=eq(uribv4Dom.name,"<TENANT:VRF>")
02-27-2019 11:12 PM
Hi
Have you tried to query just the uribv4Route-MO?
https://{{IP}}/api/class/uribv4Route.json?query-target-filter=wcard(uribv4Route.dn,"<TENANT>:<VRF>")&rsp-subtree=full&order-by=uribv4Route.dn|asc
(you need to replace <TENANT> and <VRF> with the corresponding names...)
HTH
Marcel
03-03-2019 12:50 AM
Will do.
It seems like we cannot get correct results from Cisco LAB, but we will try it on a real env and update soon.
10x!
03-04-2019 12:37 AM - edited 03-05-2019 09:18 AM
It worked! 10x!
03-14-2019 12:09 PM
FYI, you can also login to the APIC, or Switch to check the API log to see exactly how the show command output is generated. The output may not be exactly what you see, but the data structure is definitely from the API query. Log is at /var/log/dme/log/access.log
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide