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-cloud]$ 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-cloud]$ openstack object create --name mytestfile01 mycontainer01 testfile.txt
+--------------+---------------+----------------------------------+
| object       | container     | etag                             |
+--------------+---------------+----------------------------------+
| mytestfile01 | mycontainer01 | c73f47d1969e955b1cd354825b310398 |
+--------------+---------------+----------------------------------+

Once uploaded you can see the metadata through:

[lxplus-cloud]$ 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-cloud]$ openstack object save mycontainer01 mytestfile01 --file testfile.txt

Finally you can delete the object with the following command

[lxplus-cloud]$ openstack object delete mycontainer01 mytestfile01

Delete the container

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

[lxplus-cloud]$ openstack container delete mycontainer01

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

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