cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2769
Views
3
Helpful
4
Replies

Rest Query with wdcard in dn => limitation

jul.delima
Level 1
Level 1

Hello,

I'm trying (with Cobra) to retrieve some information with the Rest API. I need to retrieve the LLDP neighbors for some leaves. When I'm sending the Get REST with wildcard filter for the dn parameters, I do not receive anything back. But if I'm doing the same request but with the "eq" keyword with the full dn, I receive the information.

 

GET with target-filter "== / eq" :

https://APIC/api/class/lldpIf.json?query-target-filter=eq(lldpIf.dn,"topology/pod-1/node-112/sys/lldp/inst/if-[eth1/13]")

 

Response:

{
"totalCount": "1",
"imdata": [
{
"lldpIf": {
"attributes": {
"adminRxSt": "enabled",
"adminSt": "enabled",
"adminTxSt": "enabled",
"childAction": "",
"descr": "",
"dn": "topology/pod-1/node-112/sys/lldp/inst/if-[eth1/13]",
"id": "eth1/13",
"lcOwn": "local",
"mac": "xxxxxxx",
"modTs": "2020-06-17T15:33:16.370+01:00",
"monPolDn": "uni/fabric/monfab-default",
"name": "",
"operRxSt": "down",
"operTxSt": "down",
"portDesc": "topology/pod-1/paths-112/pathep-[eth1/13]",
"portMode": "normal",
"portVlan": "unspecified",
"status": "",
"sysDesc": "topology/pod-1/node-112",
"wiringIssues": ""
}
}
}
]
}

 

 

GET with target-filter "contains / wcard" :

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,"node-112")

Response:

{
"totalCount": "0",
"imdata": []
}

 

But If I do this kind of filter with the sysDesc paramter, it's working ! What is the limit with the dn ?

 

Thank in advance

4 Replies 4

kkhlebop
Cisco Employee
Cisco Employee

Hello jul.delima,

 

Give the wcard a shot with some asterisks for globbing. Also, I saw documentation that it might work with regex. Most likely the syntax actually leans towards regex rather then globbing (they are similar but different).

 

I noticed on this link https://www.ciscolive.com/c/dam/r/ciscolive/apjc/docs/2016/pdf/DEVNET-1627.pdf on page 17 we have this example: query-target-filter=wcard(fvTenant.description,"coke.*”) # filter with regex

 

So in your case, give these a shot, let us know if one works:

 

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,".*node-112.*")

 

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,"*node-112*")

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,"node-112.*")

 

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,"node-112*")

 

Note: the astrick might need to be urlencoded to %2A, so then might also want to try these:

 

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,".%2Anode-112.%2A")

 

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,"%2Anode-112%2A")

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,"node-112.%2A")

 

https://APIC/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,"node-112%2A")

 

Regards,

Kostia Khlebopros

Hello Kostia,

 

Thanks for your answer. I tried all the possibilites that you mentioned. Unfortunately without success. With the asterisk coding, I receive more object than expected.

 

But If I do a wildcard search with the interface name, I receive the correct answer :

 

https://{{apic}}/api/class/lldpIf.json?query-target-filter=wcard(lldpIf.dn,"eth1/49")

 

{
"totalCount": "8",
"imdata": [
{
"lldpIf": {
"attributes": {
"adminRxSt": "enabled",
"adminSt": "enabled",
"adminTxSt": "enabled",
"childAction": "",
"descr": "",
"dn": "topology/pod-1/node-101/sys/lldp/inst/if-[eth1/49]",
"id": "eth1/49",
"lcOwn": "local",

-- output ommited ---

 

By the way I needed this request to use with cobra SDK python package. But I found the "lookupByClass" method where I can put the parent DN in parameter and therefore retrieve only the class for a given node.

 

Otherwise, the workaround is to add the path in the URL and you can filter the node :

Ex :

'https://<APIC>/api/node/class/topology/pod-1/node-121/lldpIf.json?rsp-subtree=children&rsp-subtree-class=lldpIf,lldpAdjEp&rsp-subtree-include=required'

 

I am not so expert with REST in order to see if this problem is a Bug or limitation...

 

Are you working in this area ?

 

Regards


Julian de Lima

 

 

Ruben Cocheno
Spotlight
Spotlight

@jul.delima 

Just following up on this and see if you still need help?

Tag me to follow up.
Please mark it as Helpful and/or Solution Accepted if that is the case. Thanks for making Engineering easy again.
Connect with me for more on Linkedin https://www.linkedin.com/in/rubencocheno/

hrtendrup
Level 1
Level 1

Coincidentally, I ran across this post for the same use case as the OP. I have the same issues. While filtering on lldpIf.sysDesc is a feasible workaround, IMO, I'm very curious as to why lldpIf.dn is a no go.

Running ACI 4.2(7r) / 14.2(7r)

 

The queries I use:

https://apic/api/class/lldpIf.json?rsp-subtree=children&rsp-subtree-class=lldpAdjEp&rsp-subtree-include=required&query-target-filter=wcard(lldpIf.dn,"node-101")

returned 0 results (there ARE LLDP neighbors on node 101)

https://apic/api/class/lldpIf.json?rsp-subtree=children&rsp-subtree-class=lldpAdjEp&rsp-subtree-include=required&query-target-filter=wcard(lldpIf.dn,"node")

returned 6 results - 2 for each of my 3 APICs' - connections to the fabric

 

https://apic/api/class/lldpIf.json?rsp-subtree=children&rsp-subtree-class=lldpAdjEp&rsp-subtree-include=required&query-target-filter=wcard(lldpIf.dn,".*")

returned 444 results - spot check seems to indicate this would be all LLDP neighbors for the entire fabric (using Python lib - did NOT encode the * as %2A)

 

https://apic/api/class/lldpIf.json?rsp-subtree=children&rsp-subtree-class=lldpAdjEp&rsp-subtree-include=required&query-target-filter=wcard(lldpIf.dn,".*node-101.*")

returned 0 results

 

https://apic/api/class/lldpIf.json?rsp-subtree=children&rsp-subtree-class=lldpAdjEp&rsp-subtree-include=required&query-target-filter=wcard(lldpIf.sysDesc,"node-101")

returned 7 results - the 7 lldp neighbors on node 101 in my fabric - seemingly a different way to get the desired results

 

 

As a matter of testing, I tried for an entirely different class (randomly selected from my list of queries I've used). 

https://apic/api/class/fvBD.json?rsp-subtree=children&rsp-subtree-class=fvSubnet&rsp-subtree-include=required&query-target-filter=wcard(fvBD.dn,"vmware")

This returned 3 results, all with "vmware" somewhere in the dn field. This seems to work as expected.