08-15-2020 06:43 AM - edited 08-15-2020 12:31 PM
Dear reader,
Hope you are doing well.
I am looking for a moquery equivalent for the below selected options(refer the image) in the APIC.
I tried target-subtree-class=children and rsp-subtree=full. I am getting operational data(EP data, etc...) included in this. I don't these. I only need the configurable MOs
I tried to capture the query using the APIC inspector but I was unsuccessful.
Thanks.
Solved! Go to Solution.
08-18-2020 05:06 AM - edited 08-18-2020 05:06 AM
Hi
For a specific DN:
GET /api/mo/<DN>.json?rsp-subtree=full&rsp-prop-include=config-only
For a class:
GET /api/class/<CLASS>.json?rsp-subtree=full&rsp-prop-include=config-only
Examples:
GET /api/mo/uni/tn-xxx/ap-xxx-AP/epg-VLAN999-EPG.json?rsp-subtree=full&rsp-prop-include=config-only
GET /api/class/fvAEPg.json?rsp-subtree=full&rsp-prop-include=config-only
HTH
Marcel
08-15-2020 11:28 AM
Hi @AD84407
I suspect you have already seen @RedNectar's excellent write up on moquery and so you know that those controls are found
in these two -x options
-x [OPTIONS [OPTIONS ...]], --options [OPTIONS [OPTIONS ...]] Extra options to the query
From Chirs' write up:
Filter Type Syntax Description
query‑target | {self | children | subtree} | Define the scope of a query |
rsp‑subtree | {no | children | full} | Specifies child object level included in the response |
For MO Class queries that works well and you can see that a query for all fvAEPg class objects returns 5 (two default and three I have configured) as expected.
apic1# moquery -c fvAEPg -x rsp-subtree=full | grep '^name\s*:'
name : ave-ctrl
name : default
name : Web
name : App
name : DB
apic1#
apic1# moquery -c fvAEPg -x rsp-subtree=full -o xml | more <?xml version="1.0" ?> <imdata totalCount="5"> <fvAEPg annotation="" childAction="" configIssues="" configSt="applied" descr= "" dn="uni/tn-infra/ap-ave-ctrl/epg-ave-ctrl" exceptionTag="" extMngdBy="" flood OnEncap="disabled" fwdCtrl="" hasMcastSource="no" isAttrBasedEPg="no" isSharedSr vMsiteEPg="no" lcOwn="local" matchT="AtleastOne" modTs="2020-05-08T23:00:37.305+ 00:00" monPolDn="uni/tn-common/monepg-default" name="ave-ctrl" nameAlias="" pcEn fPref="unenforced" pcTag="32771" prefGrMemb="exclude" prio="unspecified" rn="epg -ave-ctrl" scope="2818048" shutdown="no" status="modified" triggerSt="triggerabl e" txId="5764607523034234882" uid="0"> <fvRsCustQosPol annotation="" childAction="" dn="uni/tn-infra/ap-ave-ctrl/ep g-ave-ctrl/rscustQosPol" extMngdBy="" forceResolve="yes" lcOwn="local" modTs="20 20-05-08T22:59:36.705+00:00" monPolDn="uni/tn-common/monepg-default" rType="mo" rn="rscustQosPol" state="formed" stateQual="default-target" status="" tCl="qosCu stomPol" tContextDn="" tDn="uni/tn-common/qoscustom-default" tRn="qoscustom-defa ult" tType="name" tnQosCustomPolName="" uid="0"/> <fvRsBd annotation="" childAction="" dn="uni/tn-infra/ap-ave-ctrl/epg-ave-ct rl/rsbd" extMngdBy="" forceResolve="yes" lcOwn="local" modTs="2020-05-08T22:59:3 6.705+00:00" monPolDn="uni/tn-common/monepg-default" rType="mo" rn="rsbd" state= "formed" stateQual="none" status="modified" tCl="fvBD" tContextDn="" tDn="uni/tn -infra/BD-ave-ctrl" tRn="BD-ave-ctrl" tType="name" tnFvBDName="ave-ctrl" uid="0" > <fvSubnetBDDefCont bddefDn="uni/bd-[uni/tn-infra/BD-ave-ctrl]-isSvc-no" ch ildAction="deleteNonPresent" dn="uni/tn-infra/ap-ave-ctrl/epg-ave-ctrl/rsbd/subn etBddefDn-[uni/bd-[uni/tn-infra/BD-ave-ctrl]-isSvc-no]" lcOwn="local" modTs="202 0-05-08T22:59:34.213+00:00" monPolDn="" name="" nameAlias="" rn="subnetBddefDn-[ uni/bd-[uni/tn-infra/BD-ave-ctrl]-isSvc-no]" status=""/> </fvRsBd> </fvAEPg> <fvAEPg annotation="" childAction="" configIssues="" configSt="applied" descr= "" dn="uni/tn-infra/ap-access/epg-default" exceptionTag="" extMngdBy="" floodOnE ncap="disabled" fwdCtrl="" hasMcastSource="no" isAttrBasedEPg="no" isSharedSrvMs iteEPg="no" lcOwn="local" matchT="AtleastOne" modTs="2020-05-08T23:00:36.863+00: 00" monPolDn="uni/tn-common/monepg-default" name="default" nameAlias="" pcEnfPre f="unenforced" pcTag="49154" prefGrMemb="exclude" prio="unspecified" rn="epg-def ault" scope="16777199" shutdown="no" status="modified" triggerSt="triggerable" t xId="5764607523034234882" uid="0"> <fvRsBd annotation="" childAction="" dn="uni/tn-infra/ap-access/epg-default/ rsbd" extMngdBy="" forceResolve="yes" lcOwn="local" modTs="2020-05-08T22:59:36.7 05+00:00" monPolDn="uni/tn-common/monepg-default" rType="mo" rn="rsbd" state="fo rmed" stateQual="none" status="modified" tCl="fvBD" tContextDn="" tDn="uni/tn-in fra/BD-default" tRn="BD-default" tType="name" tnFvBDName="default" uid="0"> <fvSubnetBDDefCont bddefDn="uni/bd-[uni/tn-infra/BD-default]-isSvc-no" chi ldAction="deleteNonPresent" dn="uni/tn-infra/ap-access/epg-default/rsbd/subnetBd defDn-[uni/bd-[uni/tn-infra/BD-default]-isSvc-no]" lcOwn="local" modTs="2020-05- 08T22:59:34.213+00:00" monPolDn="" name="" nameAlias="" rn="subnetBddefDn-[uni/b d-[uni/tn-infra/BD-default]-isSvc-no]" status=""/> --More--
For DNs moquery does NOT return what is expected. Note Total Count = 1 where I was expecting 5.
That may be what you are running into?
In @RedNectar 's article he attributes that to a bug and I have to agree.
If you do this in postman it works as expected. One of the many reasons I stay away from moquery and work directly with the REST API.
apic1# moquery -d /uni/tn-POD11_Tenant/ap-Tiered_AppProfile -x rsp-subtree=full -o xml <?xml version="1.0" ?> <imdata totalCount="1"> <fvAp annotation="" childAction="" descr="" dn="/uni/tn-POD11_Tenant/ap-Tiered_AppProfile" extMngdBy="" lcOwn="local" modTs="2020-07-23T23:06:27.235+00:00" monPolDn="uni/tn-common/monepg-default" name="Tiered_AppProfile" nameAlias="" ownerKey="" ownerTag="" prio="unspecified" rn="ap-Tiered_AppProfile" status="" uid="15374"/> </imdata> apic1#
08-15-2020 12:26 PM
Hi Claudia,
Thank you for your response. Let me rephrase my requirement.
Let's say I want to download the configuration of a specific EPG. Eg: VLAN999-EPG.
When I download using the GUI, by setting the following options:
Content: Only Configuration
Scope: Subtree
I get the following tags in the xml/json:
fvRsBd
fvRsCustQosPol
fvRsDomAtt
fvRsPathAtt
I looked up the APIC MIM Reference and these are Relations to the class fvAEPg.
But when I run this using the REST-API call /api/node/class/fvAEPg.json?query-target-filter=eq(fvAEPg.dn,"uni/tn-xxx/ap-xxx-AP/epg-VLAN999-EPG")&rsp-subtree=children, I get the following tags in the output
fvAEPg
fvCEp
fvRsCEpToPathEp and its subtags/classes These are contained MOs for the class fvAEPg
fvRsBd
fvRsCustQosPol
fvRsDomAtt
fvRsPathAtt
The fvCEp class shows the EP entries which I don't need. What options should I use so that I get only the configurable classes/tags?
To summarise, I need the output to include only the Relations of a particular class and not the Contained MOs.
08-15-2020 04:54 PM
Hi @AD84407,
So you are trying to do an moquery on a dn and I think that is the issue.
Here is the Save As result on one of my EPGs:
When I execute the moquery on the DN (my EPG in this example is App) with target children which should match the Save As (that UNI in Visore gets me the equivalent) you see you don't really get what you expected (in fact no permutation of query-target and/or rsp-subtree that I tried gets us that) so back to the issue @RedNectar highlighted in his post.
apic1# moquery -d /uni/tn-POD11_Tenant/ap-Tiered_AppProfile/epg-App -x query-target=children Total Objects shown: 1 # fv.RsBd annotation : childAction : dn : /uni/tn-POD11_Tenant/ap-Tiered_AppProfile/rsbd extMngdBy : forceResolve : yes lcOwn : local modTs : 2020-07-23T23:54:29.933+00:00 monPolDn : uni/tn-common/monepg-default rType : mo rn : rsbd state : formed stateQual : none status : tCl : fvBD tContextDn : tDn : uni/tn-POD11_Tenant/BD-POD11_BD tRn : BD-POD11_BD tType : name tnFvBDName : POD11_BD uid : 0 apic1#
In my REST call
http://{{url}}/api/node/mo/uni/tn-POD11_Tenant/ap-Tiered_AppProfile/epg-App.json?query-target=children
I do get the Save as equivalent with the REST call above:
I've attached some of the SaveAs output in a text file so you can see what I tried and the results.
Bottom Line: I don't think you will be able to do this via moquery but I do think its doable via REST.
08-15-2020 09:53 PM
Hi @Claudia de Luna,
Do you have any Endpoints available on "/uni/tn-POD11_Tenant/ap-Tiered_AppProfile/epg-App" EPG?
Thanks.
08-18-2020 05:06 AM - edited 08-18-2020 05:06 AM
Hi
For a specific DN:
GET /api/mo/<DN>.json?rsp-subtree=full&rsp-prop-include=config-only
For a class:
GET /api/class/<CLASS>.json?rsp-subtree=full&rsp-prop-include=config-only
Examples:
GET /api/mo/uni/tn-xxx/ap-xxx-AP/epg-VLAN999-EPG.json?rsp-subtree=full&rsp-prop-include=config-only
GET /api/class/fvAEPg.json?rsp-subtree=full&rsp-prop-include=config-only
HTH
Marcel
08-18-2020 05:21 AM
Hi @Marcel Zehnder ,
This is exactly what I wanted. I found the relevant documentation too.
Thank you very much.
Link to the article,
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: