Getting started
Once you get your public cloud credentials, you can create a container (bucket) and store objects. An object stores data content, such as documents, images...
Requirements : Swift Client
Some commands are not available through the OpenStack CLI, so you will need to install the Swift Client.
Ubuntu / Debian
apt install python3-swiftclient
Centos / Red Hat
yum install python3-swiftclient
Create a container
I'll create a container named public:
taylor@laptop:~ (pub1|taylor)$ openstack container create public
+---------------------------------------+-----------+------------------------------------+
| account | container | x-trans-id |
+---------------------------------------+-----------+------------------------------------+
| AUTH_d7a1d09c0323488aa00d9e163f3655bf | public | tx59c2735e9bfd4a5181079-006048ddc8 |
+---------------------------------------+-----------+------------------------------------+
List your containers
taylor@laptop:~ (pub1|taylor)$ openstack container list
+--------+
| Name |
+--------+
| public |
+--------+
Store your first object
taylor@laptop:~ (pub1|taylor)$ openstack object create --name 'eBooks/Cuisine/Les Crêpes du Monde.pdf' public 'Documents/Ebooks/Cuisine/Les Crêpes du Monde.pdf'
+----------------------------------------+-----------+----------------------------------+
| object | container | etag |
+----------------------------------------+-----------+----------------------------------+
| eBooks/Cuisine/Les Crêpes du Monde.pdf | public | a87f8e432d5c0c163d575a7fde411be8 |
+----------------------------------------+-----------+----------------------------------+
Here with --name
option I override the final object name, but it's not mandatory. By default it uses your local object name (Documents/Ebooks/Cuisine/Les Crêpes du Monde.pdf)
List your objects
You need to specify your container name...
taylor@laptop:~ (pub1|taylor)$ openstack object list public
+----------------------------------------+
| Name |
+----------------------------------------+
| eBooks/Cuisine/Les Crêpes du Monde.pdf |
+----------------------------------------+
Object versioning
Creating a bucket with versioning enabled
taylor@laptop:~ (pub1|taylor):~$ swift post -H "X-Versions-Enabled: true" mybucket
from now on, each uploaded object will be versioned with an ID. this ID is the timestamp of the upload.
taylor@laptop:~ (pub1|taylor):~$ swift upload mybucket object1
object1
taylor@laptop:~ (pub1|taylor):~$ swift upload mybucket object1
object1
Listing the objects and available versions
taylor@laptop:~ (pub1|taylor):~$ swift list mybucket --versions
183 2023-05-26 07:19:27 1685085567.70333 application/octet-stream object1
183 2023-05-26 07:19:22 1685085562.07717 application/octet-stream object1
Downloading a specific version of an object
taylor@laptop:~ (pub1|taylor):~$ swift download mybucket object1 --version-id 1685085562.07717
object1 [auth 0.471s, headers 0.691s, total 0.692s, 0.001 MB/s]
Deleting a specific version of an object
taylor@laptop:~ (pub1|taylor):~$ swift delete mybucket object1 --version-id 1685085567.70333
object1
Note
Deleting a versioned object will delete the current version but not the previous ones. Older versions are therefore still available.
taylor@laptop:~ (pub1|taylor):~$ swift delete mybucket object1
object1
taylor@laptop:~ (pub1|taylor):~$ swift list mybucket --versions
0 2023-05-26 07:21:00 1685085660.97534 application/x-deleted;swift_versions_deleted=1 object1
183 2023-05-26 07:20:54 1685085654.97972 application/octet-stream object1
183 2023-05-26 07:19:22 1685085562.07717 application/octet-stream object1
View your account statistics
taylor@laptop:~ (pub1|taylor)$ openstack object store account show
+------------+---------------------------------------+
| Field | Value |
+------------+---------------------------------------+
| Account | AUTH_d7a1d09c0323488aa00d9e163f3655bf |
| Bytes | 9149046 |
| Containers | 1 |
| Objects | 1 |
+------------+---------------------------------------+
Display capabilities
To know enabled plugins (middlewares) on our cluster, you can use:
$ swift capabilities