Usecase
You have multiple objects identified that you want to delete, for example a bunch of EPGs, some static bindings, etc. For these objects you got a DN, maybe through a moquery command.
In our example we want to delete all the EPGs in the “Network” Tenant, that have an “X” in them.
With an easy moquery command we can find the DNs of our objects.
|
|
If you want to learn more about Moquery, check out my detailed post..
Delete multiple objects by DN
Alright, we got our DNs, through whatever means :)
Now we add them to a file, which we then use to delete them. You can name the file howere you want, I go for a simple dn.txt
here.
Then but the DNs in it.
|
|
Now we are ready to launch the magic and delete the DNs from the APIC.
Please be careful! Make sure that you understand what this script does before you launch it! I can’t and won’t take any responsibility for this script and the output of it
We cat the file and then loop over each line and assume it’s a DN. With the help of icurl we delete it then from the fabric.
|
|
That’s it, the DNs are gone for good! This can be really helpful if you got a lot of DNs to delete 👍
Brackets in the DN
If you have brackets in the DN, make sure to use the icurl -g option. Otherwise you will face an error like
|
|
E.g. of the DN:
|
|