Deleting objects

Deleting objects from OpenStack Object Storage is fairly trivial, whether for small or large files.

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 the OpenStack command-line client.

How to do it…

To delete objects from our Swift cluster, carry out the following steps:

  1. List available objects in a container:
    openstack object list books
    

    This will give a list of objects in our books container:

    How to do it…
  2. Delete the object from a container:
    openstack object delete books intro.txt
    

    Note

    There will be no output from this command.

  3. List objects in the books container after deletion:
    openstack object list books
    

    The container listing will show that intro.txt is no longer present:

    How to do it…
  4. To delete all objects from a container and then delete container, issue the following command:
    openstack container delete -r books
    

    Note

    There is no output to this command.

How it works

In order to delete files from the OpenStack Object Storage cluster, specify the container and object that should be deleted with the following command:

openstack object delete container object

Use the -r flag for deleting container and all its contents.

..................Content has been hidden....................

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