01-07-2020 11:44 AM - edited 01-08-2020 11:42 AM
Hello,
I wonder if someone can give me a hand with a REST query. I've been reading the docs and trying all kinds of things but I'm just not getting what I want and I'm beginning to wonder if I'm thinking about this wrong.
what I want: A list of bridge domains that do NOT have subnets bound to them
What I've tried (all prefaced with "https://<<APIC>>/"):
'api/class/fvBD.json?query-target-filter=gt(fvSubnet.ip,"0.0.0.0")' -> no results
'api/class/fvBD.json?query-target-filter=true(fvSubnet)' -> syntax error (have not found good documentation for filter operators)
'api/class/fvBD.json?query-target=children&query-target-filter=gt(fvSubnet.ip,"0.0.0.0")' -> returns fvSubnet nodes, want vfBD nodes
'api/class/fvBD.json?target-subtree-class=fvSubnet' - returns all fvBD nodes, even ones with no subnet
'api/class/fvBD.json?query-target=subtree&target-subtree-class=fvSubnet' -> returns just fvSubnet nodes
I'm not sure if there's a correct syntax to get the APIC itself to return just the fvBD nodes that have subnets. Perhaps I have to use xpath:
Current workaround:
api/class/fvBD.xml?rsp-subtree=full
I can then use xpath to generate a list of elements that have fvSubnet as sub-elements, './/fvBD[fvSubnet]'
If anyone has any thoughts, I'd be most grateful.
Thank you.
EDIT: crossed out NOT, examples imply looking for BDs that DO have subnets. I actually want both, but I can do a diff to get the inverse. Accepted solution returns BDs with bound subnets.
Solved! Go to Solution.
01-08-2020 05:07 AM
And here is even a simplified version :-)
https://<APIC>/api/class/fvBD.json?rsp-subtree=children&rsp-subtree-class=fvSubnet&rsp-subtree-include=required
01-08-2020 12:17 AM
Hi @hrtendrup ,
To list all the BDs having a Subnet, that maybe not directly done in a single REST API, but here is the single-line moquery version (or few lines of code after the REST API /api/class/fvSubnet.json):
moquery -c fvSubnet | grep ^dn | cut -d '/' -f 2,3 | sort | uniq
01-08-2020 04:04 AM
Hi,
After some tweaking I finally got to the REST API you need:
https://<APIC>/api/class/fvTenant.json?query-target=children&target-subtree-class=fvBD&rsp-subtree=children&rsp-subtree-class=fvSubnet&rsp-subtree-include=required
Hope this helps
01-08-2020 05:07 AM
And here is even a simplified version :-)
https://<APIC>/api/class/fvBD.json?rsp-subtree=children&rsp-subtree-class=fvSubnet&rsp-subtree-include=required
01-08-2020 11:39 AM
Excellent, thank you. That's what I was looking for. I realized I misstated my initial requirement, though you figured it out via my examples. In fact, I would like to get bridge domains that DO have subnets and DO NOT have subnets. I can get the other way by doing a diff. Thank you again for your help!
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