05-11-2016 01:15 AM - edited 03-01-2019 04:57 AM
HI All,
I would like to automate ACI using cURL command and Shell script from Linux machine. I would like to use JASON scripts for ACI Configuration using this. I would like to automate below tasks using JASON script.
1 Tenant Creation
2 ZONE/VRF Creation
3 EPG Creation
4 SUBNET(IN BD) creation.
Please can anyone help me sharing the Jason script for above mentioned taks.
I have created below scripts but how to set the variable which I can pass during the scrip execution and its correct or not please comment
Authnetication
-------------------------------------------
https://192.168.1.1/api/aaaLogin.json
{
"aaaUser":{
"attributes":{
"name":"abc",
"pwd":"abc123"
}
}
}
-----------------------------------------------
Create the Tenant
POST https://192.168.1.1/api/mo/uni.json
{
"fvTenant" : {
"attributes" : {
"name" : "Jasontest"
}
}
}
------------------------------------------------------
create VRF
------------------------------------------------------
{
"fvAp":{
"attributes":{
"descr":"SCVMMZONE1",
"dn":"uni/tn-SCVMM/ap-SCVMMZONE1",
"name":"SCVMMZONE1",
"ownerKey":"",
"ownerTag":"",
"prio":"unspecified"
}
}
}
-------------------------------------------------------
EPG Creation
-------------------------------------------------------
{
"fvAEPg":{
"attributes":{
"descr":"",
"dn":"uni/tn-SCVMM/ap-SCVMMZONE1/epgSCVMMZ1EPG1",
"isAttrBasedEPg":"no",
"matchT":"AtleastOne",
"name":"SCVMMZ1EPG1",
"pcEnfPref":"unenforced",
"prio":"unspecified"
}
}
}
-----------------------------------------------
Subnet Creation
-----------------------------------------------
{
"fvSubnet":{
"attributes":{
"ctrl":"",
"descr":"",
"dn":"uni/tn-SCVMM/BD-SCVMMZ1EPG2/subnet-[10.142.32.254/24]",
"ip":"10.142.32.254/24",
"name":"",
"preferred":"yes",
"scope":"public",
"virtual":"no"
}
}
Regards,
Solved! Go to Solution.
05-11-2016 04:02 AM
Here is a some samples of json and xml...
Cheers!
T.
ADD TENANT INTO THE APIC USING CURL
===================================
LOGIN
-----
curl -X POST -k https://1.2.3.4/api/aaaLogin.json -d '{ "aaaUser" : { "attributes" : { "name" : "admin", "pwd" : "abc123!" } } }' -c cookie.txt
ie.
deadbeef:Downloads tdeleon$ curl -X POST -k https://1.2.3.4/api/aaaLogin.json -d '{ "aaaUser" : { "attributes" : { "name" : "admin", "pwd" : "abc123!" } } }' -c cookie.txt
{"totalCount":"1","imdata":[{"aaaLogin":{"attributes":{"token":"U6mpdkH5F71r8Q53vXYH1sQH4KoDztHF8Wl033CRV1IQPolSh+SXOo79Yb6yEIC3KJfyRUK/BrgPqPlldK5vBC+Wxlu36Ecsnu5B5xMI7/+CqNue9n8r7CVbIyVSqfMAeMzro20hJCW3DETkAN+5BnT0VgjJTmjzIEQ6HH4nQJo=","siteFingerprint":"Z1SRdAjhFnm5w3Mt","refreshTimeoutSeconds":"9600","maximumLifetimeSeconds":"86400","guiIdleTimeoutSeconds":"65525","restTimeoutSeconds":"90","creationTime":"1460134090","firstLoginTime":"1460134090","userName":"admin","remoteUser":"false","unixUserId":"15374","sessionId":"y2FUzQ2CSr6PSJId17UUBg==","lastName":"","firstName":"","version":"1.2(2h)","buildTime":"Tue Feb 23 20:07:23 PST 2016","node":"topology/pod-1/node-1"},"children":[{"aaaUserDomain":{"attributes":{"name":"all","rolesR":"admin","rolesW":"admin"},"children":[{"aaaReadRoles":{"attributes":{}}},{"aaaWriteRoles":{"attributes":{},"children":[{"role":{"attributes":{"name":"admin"}}}]}}]}},{"DnDomainMapEntry":{"attributes":{"dn":"comp/prov-VMware/dom-mb-fab1-vmm","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-common","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"comp/prov-VMware/ctrlr-[mb-fab1-vmm]-mb-fab1-vmm","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"topology/pod-1","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-infra","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-jk-Tenant","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/vmmp-VMware/dom-mb-fab1-vmm","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/phys-jk-Phys","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-mgmt","readPrivileges":"admin","writePrivileges":"admin"}}}]}}]}
ADD TENANT
----------
curl -b cookie.txt -X POST -k https://1.2.3.4/api/node/mo/uni/tn-deadbeef-curl.json -d '{"fvTenant":{"attributes":{"dn":"uni/tn-deadbeef-curl","name":"deadbeef-curl","descr":"Add Tenant using CURL","rn":"tn-deadbeef-curl","status":"created"},"children":[{"fvRsTenantMonPol":{"attributes":{"tnMonEPGPolName":"default","status":"created,modified"},"children":[]}}]}}'
ADD VRF
-------
curl -b cookie.txt -X POST -k https://1.2.3.4/api/node/mo/uni/tn-deadbeef-curl/ctx-curl-vrf1.json -d '{"fvCtx":{"attributes":{"dn":"uni/tn-deadbeef-curl/ctx-curl-vrf1","name":"curl-vrf1","descr":"Add VRF using CURL","rn":"ctx-curl-vrf1","status":"created"},"children":[{"fvRsCtxToEpRet":{"attributes":{"tnFvEpRetPolName":"default","status":"created,modified"},"children":[]}},{"fvRsCtxMonPol":{"attributes":{"tnMonEPGPolName":"default","status":"created,modified"},"children":[]}}]}}'
ADD BRIDGE DOMAIN
-----------------
curl -b cookie.txt -X POST -k https://1.2.3.4/api/node/mo/uni/tn-deadbeef-curl/BD-curl-bd1.json -d '{"fvBD":{"attributes":{"dn":"uni/tn-deadbeef-curl/BD-curl-bd1","mac":"00:22:BD:F8:19:FF","name":"curl-bd1","descr":"Add BD using CURL","rn":"BD-curl-bd1","status":"created"},"children":[{"fvSubnet":{"attributes":{"dn":"uni/tn-deadbeef-curl/BD-curl-bd1/subnet-[1.1.1.1/1]","ip":"1.1.1.1/1","rn":"subnet-[1.1.1.1/1]","status":"created"},"children":[]}},{"fvRsCtx":{"attributes":{"tnFvCtxName":"curl-vrf1","status":"created,modified"},"children":[]}},{"fvRsBdToEpRet":{"attributes":{"tnFvEpRetPolName":"default","status":"created,modified"},"children":[]}},{"fvRsABDPolMonPol":{"attributes":{"tnMonEPGPolName":"default","status":"created,modified"},"children":[]}}]}}'
-------------------------------
Using XML
---------
* Add Tenant with complete configuration.
LOGIN
-----
curl -X POST -k https://1.2.3.4/api/aaaLogin.xml -d '<aaaUser name="admin" pwd="abc123!"/>' -c cookie.txt
ADD TENANT
----------
curl -b cookie.txt -X POST -k https://1.2.3.4/api/node/mo/uni.xml -d "@tn-deadbeef-red.xml" -c cookie.txt
05-11-2016 04:02 AM
Here is a some samples of json and xml...
Cheers!
T.
ADD TENANT INTO THE APIC USING CURL
===================================
LOGIN
-----
curl -X POST -k https://1.2.3.4/api/aaaLogin.json -d '{ "aaaUser" : { "attributes" : { "name" : "admin", "pwd" : "abc123!" } } }' -c cookie.txt
ie.
deadbeef:Downloads tdeleon$ curl -X POST -k https://1.2.3.4/api/aaaLogin.json -d '{ "aaaUser" : { "attributes" : { "name" : "admin", "pwd" : "abc123!" } } }' -c cookie.txt
{"totalCount":"1","imdata":[{"aaaLogin":{"attributes":{"token":"U6mpdkH5F71r8Q53vXYH1sQH4KoDztHF8Wl033CRV1IQPolSh+SXOo79Yb6yEIC3KJfyRUK/BrgPqPlldK5vBC+Wxlu36Ecsnu5B5xMI7/+CqNue9n8r7CVbIyVSqfMAeMzro20hJCW3DETkAN+5BnT0VgjJTmjzIEQ6HH4nQJo=","siteFingerprint":"Z1SRdAjhFnm5w3Mt","refreshTimeoutSeconds":"9600","maximumLifetimeSeconds":"86400","guiIdleTimeoutSeconds":"65525","restTimeoutSeconds":"90","creationTime":"1460134090","firstLoginTime":"1460134090","userName":"admin","remoteUser":"false","unixUserId":"15374","sessionId":"y2FUzQ2CSr6PSJId17UUBg==","lastName":"","firstName":"","version":"1.2(2h)","buildTime":"Tue Feb 23 20:07:23 PST 2016","node":"topology/pod-1/node-1"},"children":[{"aaaUserDomain":{"attributes":{"name":"all","rolesR":"admin","rolesW":"admin"},"children":[{"aaaReadRoles":{"attributes":{}}},{"aaaWriteRoles":{"attributes":{},"children":[{"role":{"attributes":{"name":"admin"}}}]}}]}},{"DnDomainMapEntry":{"attributes":{"dn":"comp/prov-VMware/dom-mb-fab1-vmm","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-common","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"comp/prov-VMware/ctrlr-[mb-fab1-vmm]-mb-fab1-vmm","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"topology/pod-1","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-infra","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-jk-Tenant","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/vmmp-VMware/dom-mb-fab1-vmm","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/phys-jk-Phys","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-mgmt","readPrivileges":"admin","writePrivileges":"admin"}}}]}}]}
ADD TENANT
----------
curl -b cookie.txt -X POST -k https://1.2.3.4/api/node/mo/uni/tn-deadbeef-curl.json -d '{"fvTenant":{"attributes":{"dn":"uni/tn-deadbeef-curl","name":"deadbeef-curl","descr":"Add Tenant using CURL","rn":"tn-deadbeef-curl","status":"created"},"children":[{"fvRsTenantMonPol":{"attributes":{"tnMonEPGPolName":"default","status":"created,modified"},"children":[]}}]}}'
ADD VRF
-------
curl -b cookie.txt -X POST -k https://1.2.3.4/api/node/mo/uni/tn-deadbeef-curl/ctx-curl-vrf1.json -d '{"fvCtx":{"attributes":{"dn":"uni/tn-deadbeef-curl/ctx-curl-vrf1","name":"curl-vrf1","descr":"Add VRF using CURL","rn":"ctx-curl-vrf1","status":"created"},"children":[{"fvRsCtxToEpRet":{"attributes":{"tnFvEpRetPolName":"default","status":"created,modified"},"children":[]}},{"fvRsCtxMonPol":{"attributes":{"tnMonEPGPolName":"default","status":"created,modified"},"children":[]}}]}}'
ADD BRIDGE DOMAIN
-----------------
curl -b cookie.txt -X POST -k https://1.2.3.4/api/node/mo/uni/tn-deadbeef-curl/BD-curl-bd1.json -d '{"fvBD":{"attributes":{"dn":"uni/tn-deadbeef-curl/BD-curl-bd1","mac":"00:22:BD:F8:19:FF","name":"curl-bd1","descr":"Add BD using CURL","rn":"BD-curl-bd1","status":"created"},"children":[{"fvSubnet":{"attributes":{"dn":"uni/tn-deadbeef-curl/BD-curl-bd1/subnet-[1.1.1.1/1]","ip":"1.1.1.1/1","rn":"subnet-[1.1.1.1/1]","status":"created"},"children":[]}},{"fvRsCtx":{"attributes":{"tnFvCtxName":"curl-vrf1","status":"created,modified"},"children":[]}},{"fvRsBdToEpRet":{"attributes":{"tnFvEpRetPolName":"default","status":"created,modified"},"children":[]}},{"fvRsABDPolMonPol":{"attributes":{"tnMonEPGPolName":"default","status":"created,modified"},"children":[]}}]}}'
-------------------------------
Using XML
---------
* Add Tenant with complete configuration.
LOGIN
-----
curl -X POST -k https://1.2.3.4/api/aaaLogin.xml -d '<aaaUser name="admin" pwd="abc123!"/>' -c cookie.txt
ADD TENANT
----------
curl -b cookie.txt -X POST -k https://1.2.3.4/api/node/mo/uni.xml -d "@tn-deadbeef-red.xml" -c cookie.txt
05-16-2016 03:08 AM
Thanks for your reply. Today I am testing the scripts shared by you. I would like to understand below parameter passed during Tenant creation. this is mandatory or specific to your environment ? "children":[{"fvRsTenantMonPol":{"attributes":{"tnMonEPGPolName":"default","status":"created,modified"},"children":[]}}]
Also please can you share the script for epg creation which can have BD association as well.
Regards,
05-17-2016 12:31 PM
Hi Thanks for sharing the script. Above mentioned scripts are working fine. Can you share the Application profile and EPG creation scripts as I tried lot to create it but not success. Please share the Application profile and EPG creation scripts
Regards,
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide