Skip to content

Object Storage management through OpenStack common client.

Create a container

In order to create a container in the Object Storage service, you can use the openstack client with the following command.

[lxplus]$ openstack container create mycontainer01
+---------+---------------+----------------------------------------------------+
| account | container     | x-trans-id                                         |
+---------+---------------+----------------------------------------------------+
| v1      | mycontainer01 | tx000000000000000bef338-005beedb1a-1ff5583-default |
+---------+---------------+----------------------------------------------------+

Once created you can start adding objects.

Manipulate objects in a container

To upload files to a container you can use the following command

[lxplus]$ openstack object create --name mytestfile01 mycontainer01 testfile.txt
+--------------+---------------+----------------------------------+
| object       | container     | etag                             |
+--------------+---------------+----------------------------------+
| mytestfile01 | mycontainer01 | c73f47d1969e955b1cd354825b310398 |
+--------------+---------------+----------------------------------+

Once uploaded you can see the metadata through:

[lxplus]$ openstack object show mycontainer01 mytestfile01
+----------------+----------------------------------+
| Field          | Value                            |
+----------------+----------------------------------+
| account        | v1                               |
| container      | mycontainer01                    |
| content-length | 504                              |
| content-type   | text/plain                       |
| etag           | c73f47d1969e955b1cd354825b310398 |
| last-modified  | Fri, 16 Nov 2018 15:20:00 GMT    |
| object         | mytestfile01                     |
+----------------+----------------------------------+

You can retrieve the contents by using, please note that this will overwrite the file in the local directory

[lxplus]$ openstack object save mycontainer01 mytestfile01 --file testfile.txt

Finally you can delete the object with the following command

[lxplus]$ openstack object delete mycontainer01 mytestfile01

Delete the container

If you want to delete the container, you can use the following command

[lxplus]$ openstack container delete mycontainer01

If the container has some data, you can trigger the recursive option to delete the objects internally.

[lxplus]$ openstack container delete mycontainer01
Conflict (HTTP 409) (Request-ID: tx000000000000000b8058a-005beee207-20075e4-default)
[lxplus]$ openstack container delete --recursive mycontainer01

List existing containers

You can check the existing containers with

[lxplus ~]$ openstack container list
+---------------+
| Name          |
+---------------+
| mycontainer01 |
+---------------+

Space utilization

To check the overall space used, you can use the following command

[lxplus]$ openstack object store account show
+------------+---------------+
| Field      | Value         |
+------------+---------------+
| Account    | v1            |
| Bytes      | 5065108948906 |
| Containers | 81            |
| Objects    | 375322        |
+------------+---------------+

To check the space used by a specific container

[lxplus]$ openstack container show mycontainer01
+----------------+-------------------+
| Field          | Value             |
+----------------+-------------------+
| account        | v1                |
| bytes_used     | 1502              |
| container      | mycontainer01     |
| object_count   | 1                 |
| storage_policy | default-placement |
+----------------+-------------------+