OpenStack API
Cloud storage is accessible via the OpenStack API with v3 (Keystone) authentication. For more details about OpenStack Swift and Keystone, see the official documentation:
Getting access credentials for OpenStack API in the Customer Portal
To retrieve your access credentials, navigate to Cloud Storage and select the desired region. In the Access credentials section, the authorization details will be displayed based on the selected region.
Installing python-openstackclient
python-openstackclient is a command-line tool for managing OpenStack components, including cloud storage, cloud servers, and more.
macOS
Open the terminal and execute the following command:
pip install python-openstackclientUbuntu
It is recommended to install the client from the Ubuntu repository rather than using pip, as pip may provide newer versions with functional differences.
Execute the following command in the console:
sudo apt-get install python3-openstackclientAuthorization in the OpenStack API using python-openstackclient
To simplify the authorization process and avoid manually entering credentials each time, create a file with environment variables:
-
Create a
.shfile:-
On macOS, use any text editor to create a file.
-
On Ubuntu, use the built-in
nanoeditor by executing the following command:nano ~/%file-name%.shReplace
%file-name%with the name of the created file.
-
-
In the Customer Portal, go to Cloud Storage → Access Credentials and click Show next to Shell Variables.
-
Copy and paste the environment variables into the created file in the following format:
export OS_AUTH_URL=https://auth.servers.%region_id%.cloud.servers.com:5000/v3/ export OS_TENANT_NAME=XXX export OS_PASSWORD=YYY export OS_USERNAME=ZZZ export OS_IDENTITY_API_VERSION=3 export OS_DEFAULT_DOMAIN_NAME=default export OS_REGION_NAME=%region_name% -
In the
nanoeditor, save the file using the following shortcuts:- Press CTRL + O to save
- Press Enter to confirm
- Press CTRL + X to exit the editor
-
Import the environment variables into the current terminal session:
source ~/%file-name%.shReplace
%file-name%with the name of the created file.
Once loaded, the OpenStack client will use these environment variables for authorization.
Checking authorization
To ensure the authorization data has been loaded correctly, execute the following command:
openstack token issueIf successful, the command will output a token.
Useful commands
Get a list of available OpenStack commands:
openstack -hGet a list of containers in the region:
openstack container listGet a list of objects in a container:
openstack object list CONTAINER_NAMEReplace CONTAINER_NAME with the name of the container.