12-14-2017 06:58 AM
Hello,
I am trying to right a script to configure a pair of leaves that will be used as a vpc pair. I would like to be able to create the switch profiles in a single API call (L105, L106, L105-L106). However, I can't seem to get it to configure all three. It will only configure the first one listed.
Is there a way to do this or do I just need to iterate over the nodes to create the profiles.
Thanks!
Below is the payload I'm using
{
"imdata": [
{
"infraNodeP": {
"attributes": {
"descr": "",
"dn": "uni/infra/nprof-L105",
"name": "L105",
"nameAlias": "",
"ownerKey": "",
"ownerTag": ""
},
"children": [{
"infraRsAccPortP": {
"attributes": {
"tDn": "uni/infra/accportprof-IP-L105"
}
}
},
{
"infraLeafS": {
"attributes": {
"descr": "",
"name": "Leaf105",
"nameAlias": "",
"ownerKey": "",
"ownerTag": "",
"type": "range"
},
"children": [{
"infraNodeBlk": {
"attributes": {
"descr": "",
"from_": "105",
"name": "Node105",
"nameAlias": "",
"to_": "105"
}
}
}]
}
}]
}
},
{
"infraNodeP": {
"attributes": {
"descr": "",
"dn": "uni/infra/nprof-L106",
"name": "L106",
"nameAlias": "",
"ownerKey": "",
"ownerTag": ""
},
"children": [{
"infraRsAccPortP": {
"attributes": {
"tDn": "uni/infra/accportprof-IP-L106"
}
}
},
{
"infraLeafS": {
"attributes": {
"descr": "",
"name": "Leaf106",
"nameAlias": "",
"ownerKey": "",
"ownerTag": "",
"type": "range"
},
"children": [{
"infraNodeBlk": {
"attributes": {
"descr": "",
"from_": "106",
"name": "Node106",
"nameAlias": "",
"to_": "106"
}
}
}]
}
}]
}
},{
"infraNodeP": {
"attributes": {
"descr": "",
"dn": "uni/infra/nprof-L105-L106",
"name": "L105-L106",
"nameAlias": "",
"ownerKey": "",
"ownerTag": ""
},
"children": [{
"infraRsAccPortP": {
"attributes": {
"tDn": "uni/infra/accportprof-IP-L105-L106"
}
}
},
{
"infraLeafS": {
"attributes": {
"descr": "",
"name": "Leaf105-Leaf106",
"nameAlias": "",
"ownerKey": "",
"ownerTag": "",
"type": "range"
},
"children": [{
"infraNodeBlk": {
"attributes": {
"descr": "",
"from_": "105",
"name": "Node105-106",
"nameAlias": "",
"to_": "106"
}
}
}]
}
}]
}
}]
}
01-30-2018 06:34 AM
Hi Doug,
Not sure which url your posting to ? You can use "{{protocol}}://{{apic}}/api/node/mo/uni/infra.json" for this api call.
For the body you will need to iterate this one i think. Make three seperate api calls and fire them to the above api object.
Below a example of the call itself.
[{
"infraNodeP": {
"attributes": {
"descr": "",
"name": "{{Switch Policies}}"
},
"children": [{
"infraLeafS": {
"attributes": {
"descr": "",
"name": "{{Leaf Selector}}",
"type": "range"
},
"children": [{
"infraNodeBlk": {
"attributes": {
"descr": "",
"from_": "{{from}}",
"name": "{{Node-id}}",
"to_": "{{to}}"
}
}
}]
}
},
{
"infraRsAccPortP": {
"attributes": {
"tDn": "uni/infra/accportprof-{{Interface Policies}}"
}
}
}]
}
}]
It is advisable to strip all unused object from your calls to keep them readable. Also try using name formatting for the objects you create (suffix/prefix) since this will greatly help you in the future with troubleshooting and such.
Hope this helps
04-28-2023 03:12 PM
This can be done in a single call by (re)defining the parent object, then putting all the new or changed objects in the "children": [...] key of the parent.
Using your example playload, calling https://<APIC>/api/node/mo/uni/infra.json with:
{
"infraInfra": {
"attributes": {
"dn": "uni/infra"
},
"children": [
{
"infraNodeP": {...}
},
{
"infraNodeP": {...}
},
{
"infraNodeP": {...}
}
]
}
}
Notes:
The "attributes" key is required by Cisco's schema, you can't skip it and just set the "children" key.
Similarly, you can't leave the "attributes" section empty. I chose '"dn"" "uni/infra"' simply because it was the only configuration attribute of infraInfra with a value set on my APIC. Quite likely, this is necessary anyway to uniquely identify the parent (even though in this specific case there is probably only one infraInfra object).
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