Object Storage Swift - Swift commands Memo (EN)
Objective
You can use the OpenStack API to generate various scripts to automate your actions on your Public Cloud instances.
The OpenStack swiftclient allows you to interact with and manage your containers and objects. For example, you can send files regularly to your containers, in order to back them up.
In this guide, you can find the main swift commands for managing your object containers using python-swiftclient.
Requirements
- Prepare the environment to use the OpenStack API by installing python-swiftclient.
- Load the OpenStack environment variables.
Instructions
Create a PCS container
View account information
View container information
View object information
List the container(s) related to an account
List the contents of a container
Upload an object smaller than 5GB
Upload an object higher than 5GB in SLO mode
Upload an object higher than 5GB in DLO mode
LargeObject upload abortion
It is recommended that you delete the
<container_segments>or at least the segments that correspond to the dropped object.
Download an object
Delete an empty container
Delete a non-empty container
Delete an object
Delete prefix objects
Add a metadata to a container
Add metadata to an object
Delete a metadata from a container
Delete a metadata from an object
Set Read ACL on a container
Set write ACL on a container
Delete the read ACL on a container
Delete write ACL on a container
Move objects from one container to another
LargeObjects
In this example, the LargeObject was uploaded in SLO mode. See the Curl command memo documentation for the manifest upload.
On a LargeObject, the swift copy command returns a 413 error:
So we need to start by moving the segments:
Then retrieve the manifest, adapt it and re-upload it
Rename a container
You cannot rename a container. To do this, create a new container and re-upload the objects in it. However, Swift has the copy feature, which seems to provide better performance.
Time to upload 2Gb (1500 objects of 1M and 1 object of 500M):
We notice that for small objects, this does not change much. However, for objects of a slightly larger size (500M):
LargeObject
In this example, the LargeObject was uploaded in SLO mode. Please refer to the Curl Command Memo documentation for the manifest upload.
On a LargeObject, the swift copy command returns a 413 error:
So we need to start by moving the segments:
Then retrieve the manifest, adapt it and re-upload it
Get the space used in a container
There is no concept of a folder in a container, however we can use the prefixes:
Get user id
Get cluster limits
Limit container size
To limit the size of a container, simply add the metadata 'X-Container-Meta-Quota-Bytes' associated with the limit to set up:
If the limit is exceeded, the following error is returned:
Go further
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for assisting you on your specific use case of your project.
Join our community of users.