Deleting object containers

Deleting OpenStack Object Storage containers is quite simple. Any container can be deleted, for as long as they are empty.

Note

In this case, the OpenStack CLI has different behavior from the Swift CLI tool. The Swift CLI will delete container with all of its contents, while the OpenStack CLI will not. In this example, we are using the OpenStack CLI.

Getting ready

Ensure that you are logged on to a correctly configured OpenStack client and can access the OpenStack environment as a user with the swiftoperator privileges. We will use the developer user created in the Common OpenStack identity tasks recipe in Chapter 2, The OpenStack Client with the cookbook4 password. We have also granted this user the swiftoperator privileges.

Refer to Chapter 2, The OpenStack Client, for details of setting up your environment to use OpenStack command-line client.

How to do it…

To delete a Swift container in our environment, execute the following steps:

  1. First, list the available containers:
    openstack container list
    

    This will give an output like the following:

    How to do it…
  2. View container details to make sure that it is empty:
    openstack container show books
    

    This will show an output like the following:

    How to do it…
  3. Now delete the container using the following command:
    openstack container delete books
    

    Note

    There is no output from this command.

How it works…

In OpenStack Object Storage, empty containers can be deleted by a user that created them. First, we must make sure that the container is empty by viewing its details:

openstack container show container_name

Then, delete the container with the following command:

openstack container delete container_name

Verify that container is gone by listing available containers:

openstack container list
..................Content has been hidden....................

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