cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1082
Views
3
Helpful
5
Replies

How to use Object Store URL on APIC cli

Headhunter
Level 1
Level 1

Hi Community,

how can i use the Object Store URL below on the same APIC Command Line interface?

/api/node/class/mcpRtMcpIfPol.json?query-target-filter=and(wcard(mcpRtMcpIfPol.dn,"usrv"))&order-by=mcpRtMcpIfPol.modTs|desc

So i know a bit how to create moquery but sometimes it is easier to navigate to an object in APIC GUI , Open in Object Store Browser, do some filtering and then I want to use this on CLI to do some more grepping or just create a nice list.

1 Accepted Solution

Accepted Solutions

Headhunter
Level 1
Level 1

Hello @RedNectar 

I managed to get some output after searching some Cisco documentation.

There is a note in the document, and adding the port is giving the correct output.

Note: Port 7777 is specifically used to allow the APIC to query itself.

apic:~> icurl -s 'http://localhost:7777/api/class/mcpRtMcpIfPol.json?query-target-filter=wcard(mcpRtMcpIfPol.dn,"usrv")&order-by=mcpRtMcpIfPol.modTs|desc' | jq
{
"totalCount": "100",
"imdata": [
{
"mcpRtMcpIfPol": {
"attributes": {
"childAction": "",
"dn": "uni/infra/mcpIfP-mcp_enabled/rtinfraMcpIfPol-[uni/infra/funcprof/accportgrp-server1234]",
"lcOwn": "local",
"modTs": "2024-07-11T18:25:43.107+02:00",
"status": "",
"tCl": "infraAccPortGrp",
"tDn": "uni/infra/funcprof/accportgrp-server1234"
}
}
}

Thanks for you answers and i will check out more on your website regarding icurl and moquery.

Have a great day!

 

View solution in original post

5 Replies 5

RedNectar
VIP
VIP

Hi @Headhunter ,

Sounds like you need to learn how to use icurl

There are some good blog posts out there to help, some of which I've written. Make sure you include the quoted word "rednectar" in your search - although a simple search for icurl aci will probably do if you use Google.

In the meantime, try this at the APIC CLI

apic1# bash ;#To get to bash so you can enter a ? in the command
admin@apic1:~> icurl -ks "http://localhost/api/class/mcpRtMcpIfPol.json?\
query-target-filter=wcard(mcpRtMcpIfPol.dn,\"usrv\")&order-by=mcpRtMcpIfPol.modTs|desc" | jq

You can them play with "grepping" (as you say), or learn how to manipulate the output from jq to do some fancy stuff.

 

RedNectar aka Chris Welsh.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

Headhunter
Level 1
Level 1

Hi @RedNectar ,

thanks so far, but i don't get any results. Also checked your website and tried the one below and no output as well.

icurl -s http://localhost/api/node/class/fvAEPg.json | jq

I am in bash mode   apic:~>

Hi @Headhunter ,

No output for icurl -s http://localhost/api/node/class/fvAEPg.json would mean you have no fvAEPg objects. In other words, no Application End Point Groups. Put simply, no EPGs

And you would expect the same from moquery -c fvAEPg 

The filter through jq simply makes the output of the icurl readable.

So I'm not sure why you get no output (assuming you DO have EPGs and the commands are entered on an APIC rather than a leaf)

And it seems if you can't get past this point, you won't be able to refine the output to filter just the EPGs that contain the letters "usrv" etc from the GUI either (as per the original request) - after all, the only thing I did was take your original GUI URI and turn it into a format that icurl would understand by escaping the quotes characters and enclosing the whole lot in quotes. In fact I could have done it this way - enclosing your entire URI in single quotes, which I guess is closer to your original:

apic1# bash ;#To get to bash so you can enter a ? in the command
admin@apic1:~> icurl -s 'http://localhost/api/class/mcpRtMcpIfPol.json?query-target-filter=wcard(mcpRtMcpIfPol.dn,"usrv")&order-by=mcpRtMcpIfPol.modTs|desc' | jq

But when using single quotes, you can't spread the command across two lines unless you enclose each section in single quotes.

admin@apic1:~> icurl -s 'http://localhost/api/class/mcpRtMcpIfPol.json?'\
'query-target-filter=wcard(mcpRtMcpIfPol.dn,"usrv")&order-by=mcpRtMcpIfPol.modTs|desc' | jq

And of course you noticed that I didn't need the -k switch on icurl because I was using http: rather than https:

 

RedNectar aka Chris Welsh.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

Headhunter
Level 1
Level 1

Hello @RedNectar 

I managed to get some output after searching some Cisco documentation.

There is a note in the document, and adding the port is giving the correct output.

Note: Port 7777 is specifically used to allow the APIC to query itself.

apic:~> icurl -s 'http://localhost:7777/api/class/mcpRtMcpIfPol.json?query-target-filter=wcard(mcpRtMcpIfPol.dn,"usrv")&order-by=mcpRtMcpIfPol.modTs|desc' | jq
{
"totalCount": "100",
"imdata": [
{
"mcpRtMcpIfPol": {
"attributes": {
"childAction": "",
"dn": "uni/infra/mcpIfP-mcp_enabled/rtinfraMcpIfPol-[uni/infra/funcprof/accportgrp-server1234]",
"lcOwn": "local",
"modTs": "2024-07-11T18:25:43.107+02:00",
"status": "",
"tCl": "infraAccPortGrp",
"tDn": "uni/infra/funcprof/accportgrp-server1234"
}
}
}

Thanks for you answers and i will check out more on your website regarding icurl and moquery.

Have a great day!

 

Hi @Headhunter ,

Darn. I'd forgotten about port 7777 - pretty sure that port 80 has been supported for that last few versions as well as 7777, so I've rarely had to use it

RedNectar aka Chris Welsh.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

Review Cisco Networking for a $25 gift card

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