11-02-2015 08:18 AM - edited 03-01-2019 04:53 AM
Hello
I am a Network Engineer with NO scripting/programming knowledge and I am dipping my toe into the scripting (json) capabilities on my ACI fabric. One of my biggest hurdles with my new ACI fabric (at least initially) is the repetitive nature of mapping EPGs to ports. In our environment, we are migrating from a legacy 6500 and Nexus switching fabric to ACI 9k. Initially we statically mapped existing DC VLANs to EPGs, and basically statically assign those vlans/epgs to individual interfaces (and in some cases PCs and VPCs) to simulate traditional trunk ports (we do not use L2 outs on these interfaces).
So in our environment we have several hundred vlans. you can imagine that going thru the motions of statically mapping each epg to each "trunk" port gets a little tedious. So, I used the API inspector to generate a config/script template, for mapping each epg to each port. the issue is, while i can just keep modifying and pasting in this script, on a per EPG to Port basis. Is there a better way to create one LARGE JSON/XML script that encompasses each port change? i cant seem to find a way to paste in more that one change at a time, and have POSTMAN accept it. Is there something simple that I am missing? Like a special character or something? or Is that a limitation of API scripting? in that there is no way to pair multiple changes in one session? and that’s why you have to graduate to PYTHON?
example scripts...
COMBINE this change
10:11:56 DEBUG -
method: POST
url: https://10.62.60.18/api/node/mo/uni/tn-**tenetNAME/ap-***APP-PROFILE-Legacy/epg-epg-vlan10.json
payload{"fvRsPathAtt":{"attributes":{"encap":"vlan-10","instrImedcy":"immediate","tDn":"topology/pod-1/paths-101/pathep-[trunkPORTPROFILE-IntPolGrp]","status":"created"},"children":[]}}
response: {"imdata":[]}
WITH THIS CHANGE…
10:12:35 DEBUG -
method: POST
url: https://10.62.60.18/api/node/mo/uni/tn-**tenetNAME/ap-***APP-PROFILE-Legacy/epg-epg-vlan100.json
payload{"fvRsPathAtt":{"attributes":{"encap":"vlan-100","instrImedcy":"immediate","tDn":"topology/pod-1/paths-101/pathep-[trunkPORTPROFILE-IntPolGrp]","status":"created"},"children":[]}}
response: {"imdata":[]}
AND SO ON, and SO ON....
INTO ONE POST ACTION/SCRIPT
Thank you for any help!
11-03-2015 09:41 AM
Hi cowser1979,
I understand your frustration with having to manually create these EPGs and static paths.
There are a few options you can try. If you would like to continue using POSTMAN, you could try POSTing multiple fvAEPgs with children containing the static path. The important part is object and URL you use for the POST. In the following example, I'm posting multiple EPGs contained within an application profile and the URL is to the application profile itself. What this does is create the application profile along with two EPGs. In your case, you would also need to include the fvRsDom (Physical Domain association), fvRsBd (Bridge Domain association), and fvRsPathAtt (static path) as children under the fvAEPg (EPG).
For example:
URL: https://APIC_IP/api/node/mo/uni/tn-Rob-Tenant-1/ap-demo-ap-2.json
Payload:
{ "fvAp": { "attributes": { "dn": "uni/tn-Rob-Tenant-1/ap-demo-ap-2", "name": "demo-ap-2", "rn": "ap-demo-ap-2", "status": "created" }, "children": [ { "fvAEPg": { "attributes": { "dn": "uni/tn-Rob-Tenant-1/ap-demo-ap-2/epg-epg-222", "name": "epg-222", "rn": "epg-epg-222", "status": "created" }, "children": [ { "fvCrtrn": { "attributes": { "dn": "uni/tn-Rob-Tenant-1/ap-demo-ap-2/epg-epg-222/crtrn", "name": "default", "rn": "crtrn", "status": "created,modified" }, "children": [] } } ] } }, { "fvAEPg": { "attributes": { "dn": "uni/tn-Rob-Tenant-1/ap-demo-ap-2/epg-epg-223", "name": "epg-223", "rn": "epg-epg-223", "status": "created" }, "children": [ { "fvCrtrn": { "attributes": { "dn": "uni/tn-Rob-Tenant-1/ap-demo-ap-2/epg-epg-223/crtrn", "name": "default", "rn": "crtrn", "status": "created,modified" }, "children": [] } } ] } } ] } }
Your other option is to script it with Python, which will likely be easier in the long term, because modifying the JSON by hand can be time consuming and error prone.
If you are looking to get into Python programming for ACI, I would like to direct you to the ACIToolkit, Arya, and AryaLogger.
The ACIToolkit is a Python library which can make simpler ACI configuration easier to script. On the other hand Arya and AryaLogger automatically construct Cobra ACI code given JSON requests.
Information on installing Cobra can be found here:
https://developer.cisco.com/media/apicDcPythonAPI_v0.1/install.html
Hope this helps.
11-05-2015 07:14 AM
thanks!
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