Skip to main content

To configure the OpenStack CLI

Last update:

You can customize the CLI console client:

Configure OpenStack CLI using OS tools

  1. Install the OpenStack CLI.

  2. Add a service user.

  3. Download the service user 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. Make sure that the OpenStack CLI is installed:

    openstack --version

    The OpenStack CLI version number appears 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 through the OpenStack API, add a service user with permission in the Projects access area and role:

Users can be added by the Account Owner or users with the role of iam_admin.

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 in step 2Access 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 you need to manage resources of another account, in a different project or pool, or under a different service user, change the authorization details.

  1. Open the CLI.

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

    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>

    Specify <rcfile_name> is the name of the RC file you downloaded in step 3. The default is rc.sh.

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

  5. Verify that the OpenStack CLI is running. To do this, 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, the response will list them. If no servers have been created yet, the response will contain an empty string.

Configure OpenStack CLI in a Docker container

  1. Install Docker.

  2. Add a service user.

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

  4. Install the OpenStack CLI in the Docker container.

1. Install Docker

To install Docker on your local computer, use the Install Docker instructions in the official Docker documentation.

2. Add a service user

To manage project resources through the OpenStack API, add a service user with permission in the Projects access area and role:

Users can be added by the Account Owner or users with the role of iam_admin.

3. Download RC file

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

  2. Go to the Service Users section.

  3. Open the page of the service user you added in step 2Access 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 to the directory:

    mv <rcfile_name> <docker_directory>

    Specify:

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

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

    Specify <rcfile_name> is the name of the RC file you downloaded in step 3. The default is rc.sh.

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

  12. Verify that the OpenStack CLI is running. To do this, 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, the response will list them. If no servers have been created yet, the response will be empty.