Skip to main content

Configure OpenStack CLI

You can configure the CLI console client:

Configure OpenStack CLI using the OS

  1. Install OpenStack CLI.

  2. Add a service user.

  3. Download the service user RC file for authentication in the OpenStack API.

  4. Configure authorization in the OpenStack API.

1. Install 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 for working with OpenStack:

    virtualenv env
  5. Activate the virtual environment:

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

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

    openstack --version

    The OpenStack CLI version number will appear in the response. For example:

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

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

    pip3 install python-glanceclient
  10. Optional: to work with file storages, install the Manila component:

    pip3 install python-manilaclient==3.4.0

2. Add a service user

To manage project resources via the OpenStack API, add a service user with permissions in the Projects scope and the role:

Users can be added by the Account Owner or users with the iam.admin role.

3. Download the RC file

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

  1. In the control panel, in the top menu, click IAM.

  2. Go to the Service users section.

  3. Open the page of the service user you added in step 2 → the Access tab.

  4. In the RC files block:

    4.1. Select a project.

    4.2. Select a location.

    4.3. Click Download.

4. Configure authorization

For your information

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

  1. Open the CLI.

  2. Go to the directory with the RC file you downloaded in step 3:

    cd <directory_name>

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

  3. Apply the environment variables from the RC file:

    source <file_name>

    Specify <file_name> — name of the RC file you downloaded in step 3. Default is rc.sh.

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

  5. Verify that OpenStack CLI is working. To do this, open the list of cloud servers:

    openstack server list

    If cloud servers are created in the pool and project specified in the RC file, they will be listed in the response. If no servers have been created yet, an empty line will be returned.

Configure OpenStack CLI in a Docker container

  1. Install Docker.

  2. Add a service user.

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

  4. Install OpenStack CLI in a Docker container.

1. Install Docker

To install Docker on a local computer, use the Install Docker guide in the official Docker documentation.

2. Add a service user

To manage project resources via the OpenStack API, add a service user with permissions in the Projects scope and the role:

Users can be added by the Account Owner or users with the iam.admin role.

3. Download the RC file

For your information

Authentication in the OpenStack API can only be configured for one account, service user, project, and pool. If after authentication 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, in the top menu, click IAM.

  2. Go to the Service users section.

  3. Open the page of the service user you added in step 2 → the Access tab.

  4. In the RC files block:

    4.1. Select a project.

    4.2. Select a location.

    4.3. Click Download.

4. Install OpenStack CLI in a Docker container

  1. Open the CLI.

  2. Create a directory for working 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 to the directory:

    mv <file_name> <docker_directory>

    Specify:

    • <file_name> — name of the RC file you downloaded in step 3. 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 using the nano text editor:

    nano Dockerfile
  5. Add commands for installing OpenStack CLI to the Dockerfile:

    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/python-manilaclient.git@unmaintained/zed \
    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 and save your changes: press Ctrl+X, and then Y+Enter.

  7. Build the Docker container:

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

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

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

    source <file_name>

    Specify <file_name> — name of the RC file you downloaded in step 3. Default is rc.sh.

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

  12. Verify that OpenStack CLI is working. To do this, open the list of cloud servers:

openstack server list

If cloud servers are created in the pool and project specified in the RC file, they will be listed in the response. If no servers have been created yet, an empty line will be returned.