We often need to fully clean a container by deleting all the contents. Here is How to Bulk Delete OpenStack Object Storage (Swift) Objects. It is important to properly configure OpenStack Python Client first. We are using HP Cloud as client of their OpenStack Object Storage (SWIFT) service. This eventually deletes all the CDN objects as well.
Bulk Delete OpenStack Object Storage (Swift) Objects on Command Line Interface
We will use Python Swift Client. So the commands are actually documented in official website. We can test the Python Swift Client by running :
We will get an unordered list of the containers like this :
We should double check from HP Cloud web GUI to make sure what exactly we are deleting. In our example, we want to delete the contents of the container named
feeds. So, we need a positional argument and indicate to delete all with a flag. But basically, from our experience, it is better to delete the container itself :
swift delete feeds
Upon execution of the command, we will get an output. In our example, the container is published as CDN. We were using it to store XML Feeds on non-HTTPS URL for Google Feedburner. It is a fix for Feedburner’s no support for HTTPS.
Then if we can create same named container from web GUI within few seconds of deletion, the container specific setting remains intact! It remains intact or not – actually deleting a container is equivalent to deleting all the objects. Same named container can be created. We were also thinking in that complex way possibly you are searching for.
Actually we can not use * to delete all.
-all flag works a bit oddly. Second way to delete all is using auth token. We have HP Cloud specific OpenStack Object Storage (Swift) token generation guide.
Reverse of Bulk Delete is Bulk upload. That we have Python Based She Bang Script to automate the bulk upload work.
Bulk Delete OpenStack Object Storage (Swift) Objects : Mini Video Guide
Here is a very short video without any voiceover only to make you understand what exactly we do to delete all the contents of a container. Here is the video of what exactly we did :Tagged With openstack swift bulk delete , swift bulk delete , swift command bulk delete