Skip to main content
OpenStack CLI
Last update:

OpenStack CLI

The OpenStack CLI is a console client for working with the OpenStack API that is installed on the local computer. You can manage your cloud infrastructure in Selectel through the OpenStack CLI: servers, placement groups, network volumes, networks, images, load balancers.

The current versions of the components that are supported in Selectel can be viewed in the table below OpenStack component versions.

You can customize the OpenStack CLI:

OpenStack component versions

Release versionAPI version
KeystoneZed3.14
PlacementZed1.0 (maximum microversion is 1.39)
NovaZed2.1 (maximum microversion is 2.93)
NeutronUssuri2.0
CinderWallaby3.0 (maximum microversion is 3.64)
GlanceZed2.16
KarborWallaby1.0
ManilaZed2.0 (maximum microversion is 2.75)
HeatZed1.0
Octavia2023.12.26
Gnocchi4.51.0

Configure OpenStack CLI using OS tools

  1. Install the OpenStack CLI.

  2. Add a service user for authorization to the OpenStack API.

  3. Download the RC file for authorization in the OpenStack API.

  4. Configure authorization in the OpenStack API.

1. Install the OpenStack CLI

  1. Open the CLI.

  2. Install Python 3:

    sudo apt update
    sudo apt install python3
  3. Install pip3:

    sudo apt install python3-pip
  4. Install the OpenStack CLI:

    pip3 install python-openstackclient
  5. Verify that the OpenStack CLI is installed:

    openstack --version

    The version number will appear in the response.

  6. Optional: install Octavia component to work with cloud-based load balancers:

    pip3 install python-octaviaclient
  7. Optional: install the Glance component to work with the images:

    pip3 install python-glanceclient

2. Add a service user

To manage resources through the OpenStack API, you need to create a service user with the role of Project Administrator or Project Supervisor and add it to the project. If after authorization you need to manage resources under another service user, you can change the authorization data.

  1. В control panels click Account.

  2. Go to the section Users.

  3. Click Add user.

  4. Select type Service user.

  5. Enter a user name. This will be used for authorization.

  6. Enter a password for the user or generate one.

  7. Save password — once a user is created, you cannot view the password, only change it.

  8. Select user role:

    • Project administrator — can create, edit and delete project resources;
    • Project Observer — can view project resources.
  9. Check the projects to which you want to add the user.

  10. Click Add user.

3. Download RC file

To set up authorization, you need to download the service user RC file.

  1. В control panels from the top menu, press Account.

  2. Go to the section Users → tab Service users.

  3. Open the page of the service user you added the OpenStack CLI for working with OpenStack → tab Access.

  4. In the block RC files:

    4.1 Select project.

    4.2 Select region.

    4.3. Select pool.

    4.4. Press Download.

4. Set up authorization

For your information

Authorization in the OpenStack API can be configured for only one account, service user, projects и pool. If, after authorization, you need to manage the resources of another account, in another project or pool, or under a different service user, you can change the authorization data.

  1. Open the CLI.

  2. Navigate to the directory with the RC file you got when you downloading RC file for authorization in step 4.4:

    cd <directory_name>

    Specify <directory_name> — name of the directory with the RC file.

  3. Run the script from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> — RC file name, default rc.sh.

  4. Enter the OpenStack password — the password of the service user for which the RC file was created.

  5. Check the OpenStack CLI operation, for example, open the list of cloud servers:

    openstack server list

    If cloud servers have been created in the pool and project specified in the RC file, their list will appear in the command output. If no servers have been created yet, the command output will be empty.

Configure OpenStack CLI in a Docker container

  1. Install Docker.

  2. Add a service user to manage resources through the OpenStack API.

  3. Download the RC file for authorization in the OpenStack API.

  4. Install the OpenStack CLI in a Docker container.

1. Install Docker

On your local computer, install Docker. Use the instructions Install Docker in the Docker documentation.

2. Add a service user

To manage resources through the OpenStack API, you need to create a service user with the role of Project Administrator or Project Supervisor and add it to the project. If after authorization you need to manage resources under another service user, you can change the authorization data.

  1. В control panels from the top menu, press Account.

  2. Go to the section Users

  3. Click Add user.

  4. Select type Service user.

  5. Enter a user name. This will be used for authorization.

  6. Enter a password for the user or generate one.

  7. Save password — once a user is created, you cannot view the password, only change it.

  8. Select user role:

    • Project administrator — can create, edit and delete project resources;
    • Project Observer — can view project resources.
  9. Check the projects to which you want to add the user.

  10. Click Add user.

3. Download RC-file for authorization

For your information

Authorization in the OpenStack API can be configured for one only account, service user, projects и pool. If, after authorization, you need to manage the resources of another account, in another project or pool, or under a different service user, you will be able to change the authorization data.

  1. В control panels click Account.

  2. Go to the section Users → tab Service users.

  3. Open the page of the service user you added for working with OpenStack CLI → tab Access.

  4. In the block RC files:

    4.1 Select project.

    4.2 Select region.

    4.3. Select pool.

    4.4. Press Download.

4. Install OpenStack CLI in a Docker container

  1. Open the CLI.

  2. Create a directory to work with Docker:

    mkdir <docker_directory>

    Specify <docker_directory> — name of the directory where the RC file will be added and the Dockerfile will be created.

  3. Move the RC file that you received with the downloading RC file for authorization in step 4.4 to the directory:

    mv <rcfile_name.sh> <docker_directory>

    Specify:

    • <rcfile_name.sh> — the name of the RC file you received when downloading RC file for authorization in step 4.4. By default rc.sh;
    • <docker_directory> — name of the directory where the RC file will be added and the Dockerfile will be created.
  4. Create an empty Dockerfile in this directory:

    nano Dockerfile
  5. Add commands to the Dockerfile to install the OpenStack CLI:

    FROM alpine:3.17

    RUN apk add --update --no-cache python3 python3-dev libffi libffi-dev \
    git openssl openssl-dev cargo build-base iputils curl linux-headers \
    py3-pip py3-cffi py3-tz py3-pbr py3-setuptools && \
    pip3 install -UI git+https://github.com/openstack/python-openstackclient.git@stable/2024.2 \
    git+https://github.com/openstack/python-glanceclient.git@stable/2024.2 \
    git+https://github.com/openstack/python-octaviaclient.git@stable/2024.2 \
    && apk del build-base linux-headers python3-dev libffi-dev openssl-dev git cargo iputils curl && rm -rf /var/cache

    CMD ["sh"]
  6. Exit the text editor nano while saving changes: press Ctrl+Xand then Y+Enter.

  7. Build a Docker container:

    docker build -t osc:dalmatian .
  8. Start the Docker container:

    docker run -ti --rm -v $(pwd):/workspace osc:dalmatian
  9. Go to the directory workspace:

    cd /workspace
  10. Run the script from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> — the name of the RC file you received when downloading RC file for authorization in step 4.4 and moved it to the directory with the Dockerfile. By default rc.sh

  11. Verify the OpenStack CLI is working, for example, by opening the list of cloud servers:

    openstack server list

    If cloud servers have been created in the pool and project specified in the RC file, the command output will list them. If no servers have been created yet, the command output will be empty.

Change authorization data

If you need to manage the resources of another account, project, pool or under a different service user, change the authorization details.

The process of changing data depends on how you have configured OpenStack API authorization:

Change authorization data in the OS

  1. Open the CLI.

  2. Open the RC file in a text editor nano:

    nano /<directory_name>/<rcfile_name.sh>

    Specify:

    • <directory_name> — the name of the directory with the RC file and Dockerfile;
    • <rcfile_name.sh> — the name of the RC file you received when downloading RC file for authorization in step 4.4. By default rc.sh
  3. Change the data in the file:

    export OS_PROJECT_DOMAIN_NAME='<account_id>'
    export OS_PROJECT_ID='<project_id>'
    export OS_TENANT_ID='<project_id>'
    export OS_REGION_NAME='<pool>'

    export OS_USER_DOMAIN_NAME='<account_id>'
    export OS_USERNAME='<user_name>'

    Specify:

    • <account_id> — control panel account number. You can look in control panels in the upper right hand corner;
    • <project_id> — Project ID. Can be copied to control panels: from the top menu, press Products and select Cloud servers → open the project menu (name of the current project) → in the line of the desired project, click ;
    • <pool> — pool for example ru-2;
    • <user_name> — the name of the service user you added to manage resources through the OpenStack CLI. You can view it in the control panel: from the top menu, click AccountUsers → tab Service users.
  4. Exit the text editor nano while saving changes: press Ctrl+Xand then Y+Enter.

  5. Run the script from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> — the name of the RC file you received when downloading RC file for authorization in step 4.4. By default rc.sh

  6. Enter the OpenStack password, which is the password for the service user for which you are downloaded the RC file in step 4.4.

  7. Check the OpenStack CLI operation, for example, open the list of cloud servers:

    openstack server list

    If cloud servers have been created in the pool and project specified in the variables, their list will appear in the command output. If no servers have been created yet, the command output will be empty.

Change authorization data in Docker container

  1. Open the CLI.

  2. Open the RC file in a text editor nano:

    nano /<docker_directory>/<rcfile_name.sh>

    Specify:

    • <docker_directory> — name of the directory with the added RC file and Dockerfile;
    • <rcfile_name.sh> — the name of the RC file you received when downloading RC file for authorization in step 4.4. By default rc.sh
  3. Change the data in the file:

    export OS_PROJECT_DOMAIN_NAME='<account_id>'
    export OS_PROJECT_ID='<project_id>'
    export OS_TENANT_ID='<project_id>'
    export OS_REGION_NAME='<pool>'

    export OS_USER_DOMAIN_NAME='<account_id>'
    export OS_USERNAME='<user_name>'

    Specify:

    • <account_id> — control panel account number. You can look in control panels in the upper right hand corner;
    • <project_id> — Project ID. Can be copied to control panels: from the top menu, press Products and select Cloud servers → open the project menu (name of the current project) → in the line of the desired project, click ;
    • <pool> — pool for example ru-2;
    • <user_name> — the name of the service user you added to manage resources through the OpenStack CLI. You can look at control panels: from the top menu, press AccountUsers → tab Service users.
  4. Exit the text editor nano while saving changes: press Ctrl+Xand then Y+Enter.

  5. Start the Docker container:

    docker run -ti --rm -v $(pwd):/workspace osc:dalmatian
  6. Run the script from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> — the name of the RC file you received when downloading RC file for authorization in step 4.4. By default rc.sh.

  7. Enter the OpenStack password — the password of the service user for which the RC file was created.

  8. Check the OpenStack CLI operation, for example, open the list of cloud servers:

    openstack server list

    If cloud servers have been created in the pool and project specified in the variables, their list will appear in the command output. If no servers have been created yet, the command output will be empty.