Deleting containers and objects

The swift client tool allows us to directly delete containers and objects within our OpenStack Object Storage environment.

Getting ready

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

How to do it...

We will delete objects in our OpenStack Object Storage environment using different swift client options.

Deleting objects

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.

Deleting multiple objects

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.

Deleting containers

To delete our test container, we issue the following command:

swift delete test

This will delete the container, any objects under this container, and any segment objects if the object was split when originally uploaded.

Deleting everything from our account

To delete all containers and objects in our account, we issue the following command:

swift delete --all

This will delete all containers and any objects under these containers.

How it works...

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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset