12-05-2022 10:08 PM
Hi Everyone,
I am busy testing a postman script to configure and remove static routes on the APIC(physical lab. version 4.2(7f)).
Below is the json script in postman and I use a runner to reference a .csv for a list of ip addresses:
Solved! Go to Solution.
12-06-2022 12:12 AM
Hi @DuaBell
As far as I see, not the full json body is listed. Can you share it all?
Also, how do you perform the "creation" and "deletion" action? Do you send a POST for "creation" and a DELETE for "deletion"?
Or you always send a POST and change the "status" attribute from "created" to "deleted"?
My guess is that you use a "DELETE" method against the "l3extRsNodeL3OutAtt" object, which if this is the case, then it's expected what you see. The correct way should be to always use POST method and use "status" attribute.
Example:
Create static route:
Method: POST
URL: https://{{apic_ip}}/api/mo/uni/tn-{{tn_name}}/out-{{l3out_name}}/lnodep-{{nodeProfile_name}}.json
Body:
{
"ipRouteP": {
"attributes": {
"aggregate": "no",
"annotation": "",
"descr": "{{route_description}}",
"dn": "uni/tn-{{tn_name}}/out-{{l3out_name}}/lnodep-{{nodeProfile_name}}/rsnodeL3OutAtt-[topology/pod-1/node-{{node_id}}]/rt-[{{prefix}}]",
"fromPfxLen": "0",
"ip": "{{prefix}}",
"name": "",
"nameAlias": "",
"pref": "1",
"rtCtrl": "",
"toPfxLen": "0",
"status":"created"
},
"children": [
{
"ipNexthopP": {
"attributes": {
"annotation": "",
"descr": "{{nh_description}}",
"name": "",
"nameAlias": "",
"nhAddr": "{{next_hop}}",
"pref": "unspecified",
"type": "prefix"
}
}
}
]
}
}
Delete static route:
Method: POST
URL: https://{{apic_ip}}/api/mo/uni/tn-{{tn_name}}/out-{{l3out_name}}/lnodep-{{nodeProfile_name}}.json
Body:
{
"ipRouteP": {
"attributes": {
"aggregate": "no",
"annotation": "",
"descr": "{{route_description}}",
"dn": "uni/tn-{{tn_name}}/out-{{l3out_name}}/lnodep-{{nodeProfile_name}}/rsnodeL3OutAtt-[topology/pod-1/node-{{node_id}}]/rt-[{{prefix}}]",
"fromPfxLen": "0",
"ip": "{{prefix}}",
"name": "",
"nameAlias": "",
"pref": "1",
"rtCtrl": "",
"toPfxLen": "0",
"status":"deleted"
},
"children": [
{
"ipNexthopP": {
"attributes": {
"annotation": "",
"descr": "{{nh_description}}",
"name": "",
"nameAlias": "",
"nhAddr": "{{next_hop}}",
"pref": "unspecified",
"type": "prefix"
}
}
}
]
}
}
Take care,
Sergiu
12-06-2022 01:29 AM
You don't have to send all attributes. Just the mandatory ones (same as in GUI).
Also, if the route (or any other MO you want to change via API) is already configured, and you want to change any attributes, you must use the following status:
"status":"created,modified"
Take care,
Sergiu
12-06-2022 12:12 AM
Hi @DuaBell
As far as I see, not the full json body is listed. Can you share it all?
Also, how do you perform the "creation" and "deletion" action? Do you send a POST for "creation" and a DELETE for "deletion"?
Or you always send a POST and change the "status" attribute from "created" to "deleted"?
My guess is that you use a "DELETE" method against the "l3extRsNodeL3OutAtt" object, which if this is the case, then it's expected what you see. The correct way should be to always use POST method and use "status" attribute.
Example:
Create static route:
Method: POST
URL: https://{{apic_ip}}/api/mo/uni/tn-{{tn_name}}/out-{{l3out_name}}/lnodep-{{nodeProfile_name}}.json
Body:
{
"ipRouteP": {
"attributes": {
"aggregate": "no",
"annotation": "",
"descr": "{{route_description}}",
"dn": "uni/tn-{{tn_name}}/out-{{l3out_name}}/lnodep-{{nodeProfile_name}}/rsnodeL3OutAtt-[topology/pod-1/node-{{node_id}}]/rt-[{{prefix}}]",
"fromPfxLen": "0",
"ip": "{{prefix}}",
"name": "",
"nameAlias": "",
"pref": "1",
"rtCtrl": "",
"toPfxLen": "0",
"status":"created"
},
"children": [
{
"ipNexthopP": {
"attributes": {
"annotation": "",
"descr": "{{nh_description}}",
"name": "",
"nameAlias": "",
"nhAddr": "{{next_hop}}",
"pref": "unspecified",
"type": "prefix"
}
}
}
]
}
}
Delete static route:
Method: POST
URL: https://{{apic_ip}}/api/mo/uni/tn-{{tn_name}}/out-{{l3out_name}}/lnodep-{{nodeProfile_name}}.json
Body:
{
"ipRouteP": {
"attributes": {
"aggregate": "no",
"annotation": "",
"descr": "{{route_description}}",
"dn": "uni/tn-{{tn_name}}/out-{{l3out_name}}/lnodep-{{nodeProfile_name}}/rsnodeL3OutAtt-[topology/pod-1/node-{{node_id}}]/rt-[{{prefix}}]",
"fromPfxLen": "0",
"ip": "{{prefix}}",
"name": "",
"nameAlias": "",
"pref": "1",
"rtCtrl": "",
"toPfxLen": "0",
"status":"deleted"
},
"children": [
{
"ipNexthopP": {
"attributes": {
"annotation": "",
"descr": "{{nh_description}}",
"name": "",
"nameAlias": "",
"nhAddr": "{{next_hop}}",
"pref": "unspecified",
"type": "prefix"
}
}
}
]
}
}
Take care,
Sergiu
12-06-2022 12:42 AM
Hi Sergiu,
Thanks for your prompt and valuable response.
I was sending a POST for creation and a DELETE for deletion of static routes. I see where i made my mistake and i did not send a POST to change the STATUS attribute (which makes sense). I will adjust the script and test again....
One more question, when creating the json script do I have to add all the attributes or can I only add those attributes that I want to change?
12-06-2022 01:29 AM
You don't have to send all attributes. Just the mandatory ones (same as in GUI).
Also, if the route (or any other MO you want to change via API) is already configured, and you want to change any attributes, you must use the following status:
"status":"created,modified"
Take care,
Sergiu
12-06-2022 02:21 AM
thanks, I will add that to my test.
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