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-openstackclient

Ubuntu

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-openstackclient

Authorization 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:

  1. Create a .sh file:

    • On macOS, use any text editor to create a file.

    • On Ubuntu, use the built-in nano editor by executing the following command:

      nano ~/%file-name%.sh

      Replace %file-name% with the name of the created file.

  2. In the Customer Portal, go to Cloud StorageAccess Credentials and click Show next to Shell Variables.

  3. 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%
  4. In the nano editor, save the file using the following shortcuts:

    • Press CTRL + O to save
    • Press Enter to confirm
    • Press CTRL + X to exit the editor
  5. Import the environment variables into the current terminal session:

    source ~/%file-name%.sh

    Replace %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 issue

If successful, the command will output a token.

Useful commands

Get a list of available OpenStack commands:

openstack -h

Get a list of containers in the region:

openstack container list

Get a list of objects in a container:

openstack object list CONTAINER_NAME

Replace CONTAINER_NAME with the name of the container.

On this page