Creating object containers

To get started using OpenStack Object Storage, we must first create a container. A container in this case is quite similar to a folder on Windows or Linux file directory. However, containers cannot be nested, though deep structures can be created in a fashion similar to the nested folder structure using both container and object names (pseudo folders) when we come to uploading the objects that are stored in these containers. Names we assigned containers and objects are analogous to labels that allow us to interpret as folder structures through the use of a / character in these labels.

Getting ready

Ensure that you are logged on to a correctly configured OpenStack client as described in Chapter 2, The 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 with the swiftoperator privileges.

Tip

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 create a Swift container on our environment, follow these steps:

  1. To create a container, execute the following command:
    openstack container create books
    
  2. Once the container is created, you will see the following output:
    How to do it…
  3. To view all the available containers, type this command:
    openstack container list
    

    This will give an output like the following:

    How to do it…
  4. Once the container is created, we can set additional details or metadata on it by executing the following command:
    openstack container set books --property title=cookbooks
    
  5. To view container details, type the following command:
    openstack container show books
    

    This will give the following output:

    How to do it…
  6. As described in the introduction, names that we assigned to containers and objects are very much like labels; so, to create a pseudo-folder in the container, use / delimiter in the container name:
    openstack container create books/chapter1
    

    This will return output like the following:

    How to do it…
  7. To view details of the pseudo-folder, execute the container show command by including the full pseudo-folder name:
    openstack container show books/chapter1
    

    This will give the information like the following:

    How to do it…

How it works…

In OpenStack Object Storage, users with the admin or swiftoperator privileges can utilize the Object Storage service. To do so, we first must create containers, where the objects will be stored. Containers may not be nested, though we may create pseudo-folders using the / delimiter in the container name. To create a container, follow this command-line syntax:

openstack container create container_name

To list available containers, use the following command:

openstack container list

We can also set metadata on each container. Use the following command for setting additional info on a container:

openstack container set container_name
    --property key=value

Multiple pairs of metadata may be set on each container.

To view container details, execute this command:

openstack container show <container_name>
..................Content has been hidden....................

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