cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
266
Views
0
Helpful
2
Replies
jul.delima
Beginner

Rest Query with wdcard in dn => limitation

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

2 REPLIES 2
kkhlebop
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

 

 

Content for Community-Ad

This widget could not be displayed.