cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2244
Views
5
Helpful
4
Replies

ACI REST API custom reporting

hrtendrup
Level 1
Level 1

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.

1 Accepted Solution

Accepted Solutions

And here is even a simplified version :-)

https://<APIC>/api/class/fvBD.json?rsp-subtree=children&rsp-subtree-class=fvSubnet&rsp-subtree-include=required

 

Remi Astruc

View solution in original post

4 Replies 4

Remi-Astruc
Cisco Employee
Cisco Employee

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

 

Remi Astruc

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

 

Remi Astruc

And here is even a simplified version :-)

https://<APIC>/api/class/fvBD.json?rsp-subtree=children&rsp-subtree-class=fvSubnet&rsp-subtree-include=required

 

Remi Astruc

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!

Save 25% on Day-2 Operations Add-On License