Skip to main content
OpenStack CLI
Last update:

OpenStack CLI

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

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

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 to authorize to the OpenStack API.

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

  4. Configure authorization in the OpenStack API.

1. Install the OpenStack CLI

  1. Open the CLI.

  2. Install Python 3 and virtualenv:

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

    sudo apt install python3-pip
  4. Create a virtual environment to work with OpenStack:

    virtualenv env
  5. Activate the virtual environment:

    source env/bin/activate
  6. Install the OpenStack CLI in a virtualized environment:

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

    openstack --version

    The version number will appear in the response.

  8. Optional: install the Octavia component to work with cloud load balancers:

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

    pip3 install python-glanceclient

2. Add a service user

To manage resources via OpenStack API, you need to create a service user with the role of Project Administrator or Project Observer 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. In the control panel, click Account.

  2. Go to the Service Users section.

  3. Click Add User.

  4. Select the Service User type.

  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 a 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. In the control panel, on the top menu, click Account.

  2. Go to the Service Users section.

  3. Open the page of the service user you added to work with the OpenStack CLIAccess tab.

  4. RC files in the block:

    4.1 Select a project.

    4.2 Select a region.

    4.3 Select a pool.

    4.4. Click Download.

4. Set up authorization

For your information

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

  1. Open the CLI.

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

    cd <directory_name>

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

  3. Apply the environment variables from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> is the name of the RC file you received when you downloaded the RC file for authorization in step 4.4. The default is rc.sh.

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

  5. 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, 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 to the OpenStack API.

  4. Install the OpenStack CLI in the Docker container.

1. Install Docker

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

2. Add a service user

To manage resources via OpenStack API, you need to create a service user with the role of Project Administrator or Project Observer 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. In the control panel, on the top menu, click Account.

  2. Go to the Service Users section

  3. Click Add Service User.

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

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

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

  7. Select a user role:

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

  9. Click Add User.

3. Download RC-file for authorization

For your information

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

  1. In the control panel, click Account.

  2. Go to the Service Users section.

  3. Open the page of the service user you added to work with the OpenStack CLIAccess tab.

  4. RC files in the block:

    4.1 Select a project.

    4.2 Select a region.

    4.3 Select a pool.

    4.4. Click 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> — the name of the directory where the RC file will be added and the Dockerfile will be created.

  3. Move the RC file you received when you downloaded the RC file for authorization in step 4.4 to the directory:

    mv <rcfile_name.sh> <docker_directory>

    Specify:

    • <rcfile_name.sh> — name of the RC file you received when downloading the RC file for authorization in step 4.4. The default is. 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 \
    git+https://github.com/openstack/osc-lib.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 nano text editor with your changes saved: press Ctrl+X and 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. Navigate to the workspace directory:

    cd /workspace
  10. Apply the environment variables from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> is the name of the RC file that you obtained when you downloaded the RC file for authorization in step 4.4 and moved it to the directory with the Dockerfile. The default is rc.sh

  11. Enter the OpenStack password — the password of the service user for which you downloaded the RC file in step 4.4.

  12. 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.

Start the OpenStack CLI

The OpenStack CLI startup process depends on how you have configured OpenStack API authorization:

Start the OpenStack CLI in the OS

  1. Open the CLI.

  2. Apply the environment variables from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> is the name of the RC file you received when you downloaded the RC file for authorization in step 4.4. The default is rc.sh

  3. Enter the OpenStack password — the password of the service user for which you downloaded the RC file in step 4.4.

  4. 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 variables, the command output will list them. If no servers have been created yet, the command output will be empty.

Run the OpenStack CLI in a Docker container

  1. Open the CLI.

  2. Start the Docker container:

    docker run -ti --rm -v $(pwd):/workspace osc:dalmatian
  3. Apply the environment variables from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> is the name of the RC file you received when you downloaded the RC file for authorization in step 4.4. The default is rc.sh.

  4. Enter the OpenStack password — the password of the service user for which you downloaded the RC file in step 4.4.

  5. 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 variables, the command output will list them. If no servers have been created yet, the command output will be empty.

    After working with the OpenStack CLI, log out of the Docker container:

    exit

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 the nano text editor:

    nano /<directory_name>/<rcfile_name.sh>

    Specify:

    • <directory_name> — name of the directory with the RC file and Dockerfile;
    • <rcfile_name.sh> — name of the RC file you received when downloading the RC file for authorization in step 4.4. The 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. Can be viewed in control panel in the upper right corner;
    • <project_id> — Project ID. Can be copied in control panel: in the top menu click Products and select Cloud Servers → open the projects menu (name of the current project) → in the row of the desired project, press ;
    • <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 Account → section Service Users.
  4. Exit the nano text editor with your changes saved: press Ctrl+X and then Y+Enter.

  5. Apply the environment variables from the RC file:

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> is the name of the RC file you received when you downloaded the RC file for authorization in step 4.4. The default is rc.sh

  6. Enter the OpenStack password — the password of the service user for which you downloaded the RC file in step 4.4.

  7. 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 variables, the command output will list them. 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 the nano text editor:

    nano /<docker_directory>/<rcfile_name.sh>

    Specify:

    • <docker_directory> — name of the directory with added RC file and Dockerfile;
    • <rcfile_name.sh> — name of the RC file you received when downloading the RC file for authorization in step 4.4. The 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. Can be viewed in control panel in the upper right corner;
    • <project_id> — Project ID. Can be copied in control panel: in the top menu click Products and select Cloud Servers → open the projects menu (name of the current project) → in the row of the desired project, press ;
    • <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: in the top menu, click Account → section Service Users.
  4. Exit the nano text editor with your changes saved: press Ctrl+X and then Y+Enter.

  5. Start the Docker container:

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

    source <rcfile_name.sh>

    Specify <rcfile_name.sh> is the name of the RC file you received when you downloaded the RC file for authorization in step 4.4. The default is rc.sh.

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

  8. 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 variables, the command output will list them. If no servers have been created yet, the command output will be empty.