The swift
client tool allows us to directly delete containers and objects within our OpenStack Object Storage environment.
Ensure you are logged in to a Ubuntu host that has access to our OpenStack environment on the 192.168.100.0/24 public network. This host will be used to run client tools against the OpenStack environment created. If you are using the accompanying Vagrant environment, as described in the Preface, you can use the controller
node. It has the python-swiftclient
package that provides the swift
command-line client.
If you created this node with Vagrant, you can execute the following command:
vagrant ssh controller
Ensure you have set the following credentials (adjust the path to your certificates and key file to match your environment if not using the Vagrant environment):
export OS_TENANT_NAME=cookbook export OS_USERNAME=admin export OS_PASSWORD=openstack export OS_AUTH_URL=https://192.168.100.200:5000/v2.0/ export OS_NO_CACHE=1 export OS_KEY=/vagrant/cakey.pem export OS_CACERT=/vagrant/ca.pem
We will delete objects in our OpenStack Object Storage environment using different swift
client options.
To delete the object tmp/test/test1
, we issue the following command:
swift delete test tmp/test/test1
This deletes the tmp/test/test1
object from the test
container.
To delete the tmp/test/test2
and tmp/example-500Mb
objects, we issue the following command:
swift delete test tmp/test/test2 tmp/example-500Mb
This deletes the tmp/test/test2
and tmp/example-500Mb
objects from the test
container.
The swift
client is a basic but versatile tool that allows us to do many of the things we want to do with files. You can delete objects and containers using the following syntax:
swift delete {container_name} {object … }
To download all objects from our account (for example, from all containers), we use the following syntax:
swift delete --all