---
title: "Configure OpenStack CLI"
sidebar_label: "Configure OpenStack CLI"
sidebar_position: 2
description: "How to install the console client for working with OpenStack API and configure authorization"
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import CopyIcon from '@selectel/docux/icons/copy'
import {TabItemLabel} from '@selectel/docux/components'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Configure OpenStack CLI

You can configure the CLI console client:

* [using the operating system](#configure-openstack-in-os);
* in a [Docker container](#configure-openstack-in-docker-container).

## Configure OpenStack CLI using the OS \{#configure-openstack-in-os}

1. [Install OpenStack CLI](#install-openstack-cli).

2. [Add a service user](#add-service-user-for-os).

3. [Download the service user RC file for authorization in OpenStack API](#download-rc-file-for-os).

4. [Configure authorization in OpenStack API](#configure-authorization-in-os).

### 1. Install OpenStack CLI \{#install-openstack-cli}

<Tabs queryString="install-openstack-cli">
  <TabItem value="ubuntu-debian" default>
    <TabItemLabel>
      Ubuntu/Debian
    </TabItemLabel>

    1. Open the CLI.

    2. Install Python 3 and `virtualenv`:

       ```bash
       sudo apt update
       sudo apt install python3 virtualenv
       ```

    3. Install `pip3`:

       ```bash
       sudo apt install python3-pip
       ```

    4. Create a virtual environment for working with OpenStack:

       ```bash
       virtualenv env
       ```

    5. Activate the virtual environment:

       ```bash
       source env/bin/activate
       ```

    6. Install OpenStack CLI in the virtual environment:

       ```bash
       pip3 install python-openstackclient
       ```

    7. Verify that OpenStack CLI is installed:

       ```bash
       openstack --version
       ```

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

       ```bash
       openstack 6.1.0
       ```

    8. Optional: to work with [cloud load balancers](/cloud-servers/load-balancers/), install the Octavia component:

       ```bash
       pip3 install python-octaviaclient
       ```

    9. Optional: to work with [cloud server images](/cloud-servers/images/), install the Glance component:

       ```bash
       pip3 install python-glanceclient
       ```

    10. Optional: to work with [file storages](/file-storage/), install the Manila component:

        ```bash
        pip3 install python-manilaclient==3.4.0
        ```
  </TabItem>

  <TabItem value="centos">
    <TabItemLabel>
      CentOS
    </TabItemLabel>

    1. Open the CLI.

    2. Install Python 3, `virtualenv` and `pip3`:

       ```bash
       sudo dnf update -y
       sudo dnf install python3 -y
       sudo dnf install virtualenv -y
       sudo dnf install python3-pip -y
       ```

    3. Install OpenStack CLI in the virtual environment:

       ```bash
       pip3 install python-openstackclient
       ```

    4. Verify that OpenStack CLI is installed:

       ```bash
       openstack --version
       ```

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

       ```bash
       openstack 6.1.0
       ```

    5. Optional: to work with [cloud load balancers](/cloud-servers/load-balancers), install the Octavia component:

       ```bash
       pip3 install python-octaviaclient
       ```

    6. Optional: to work with [cloud server images](/cloud-servers/images/), install the Glance component:

       ```bash
       pip3 install python-glanceclient
       ```

    7. Optional: to work with [file storages](/file-storage/), install the Manila component:

       ```bash
       pip3 install python-manilaclient==3.4.0
       ```
  </TabItem>

  <TabItem value="macos">
    <TabItemLabel>
      macOS
    </TabItemLabel>

    1. Open the CLI.

    2. Install Python 3 and `pip3`:

       ```bash
       brew install python3
       ```

    3. Install `virtualenv`:

       ```bash
       pip3 install virtualenv
       ```

    4. Install OpenStack CLI in the virtual environment:

       ```bash
       brew install openstackclient
       ```

    5. Verify that OpenStack CLI is installed:

       ```bash
       openstack --version
       ```

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

       ```bash
       openstack 6.1.0
       ```

    6. Optional: to work with [cloud load balancers](/cloud-servers/load-balancers), install the Octavia component:

       ```bash
       pip3 install python-octaviaclient
       ```

    7. Optional: to work with [images](/cloud-servers/images/), install the Glance component:

       ```bash
       pip3 install python-glanceclient
       ```

    8. Optional: to work with [file storages](/file-storage/), install the Manila component:

       ```bash
       pip3 install python-manilaclient==3.4.0
       ```
  </TabItem>

  <TabItem value="windows">
    <TabItemLabel>
      Windows
    </TabItemLabel>

    1. Install Python, for example [Python 3.12.0](https://www.python.org/downloads/release/python-3120/). During installation, select the **Add python.exe to PATH** checkbox.

    2. Install [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/). During installation, under **Workloads** in the **Desktop & Mobile** block, select the **Desktop development with C++** checkbox.

    3. Open the CLI.

    4. Install OpenStack CLI:

       ```bash
       pip3 install python-openstackclient
       ```

    5. Verify that OpenStack CLI is installed:

       ```bash
       openstack --version
       ```

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

       ```bash
       openstack 6.1.0
       ```

    6. Optional: to work with [cloud load balancers](/cloud-servers/load-balancers), install the Octavia component:

       ```bash
       pip3 install python-octaviaclient
       ```

    7. Optional: to work with [cloud server images](/cloud-servers/images/), install the Glance component:

       ```bash
       pip3 install python-glanceclient
       ```

    8. Optional: to work with [file storages](/file-storage/), install the Manila component:

       ```bash
       pip3 install python-manilaclient==3.4.0
       ```
  </TabItem>
</Tabs>

### 2. Add a service user \{#add-service-user-for-os}

To manage project resources via OpenStack API, [add a service user](/access-control/manage/add-user.mdx#add-service-user) with access in the **Projects** scope and a role:

* `member;`
* or [`reader`](/access-control/role-reference.mdx#reader).

Users can be added by the [Account Owner](/access-control/user-types.mdx#account-owner) or users with the [`iam.admin`](/access-control/role-reference.mdx#iam-admin) role.

### 3. Download the RC file \{#download-rc-file-for-os}

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

1. In the [control panel](https://my.selectel.ru/iam/service-users), on 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](#add-service-user-for-os) → **Access** tab.

4. In the **RC files** block:

   4.1. Select a [project](/access-control/projects/about-projects.mdx).

   4.2. Select a [location](/infrastructure/locations.mdx).

   4.3. Click **Download**.

### 4. Configure authorization \{#configure-authorization-in-os}

:::info

Authorization for the OpenStack API can be configured for only one [account](/account/), [service user](/access-control/access-management.mdx#roles), [project](/access-control/projects/about-projects.mdx), and [pool](/infrastructure/locations.mdx#pool). If you need to manage resources of another account, in a different project or pool, or under a different service user, [change your authorization data](/cloud-servers/tools/openstack-cli/change-authorization-data.mdx).

:::

<Tabs queryString="configure-authorization-in-os">
  <TabItem value="unix" default>
    <TabItemLabel>
      Linux/macOS
    </TabItemLabel>

    1. Open the CLI.

    2. Go to the directory containing the RC file you [downloaded in step 3](#download-rc-file-for-os):

       ```bash
       cd <directory_name>
       ```

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

    3. Apply the environment variables from the RC file:

       ```bash
       source <file_name>
       ```

       Specify `<file_name>` — the name of the RC file that you [downloaded in step 3](#download-rc-file-for-os). The 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](#download-rc-file-for-os).

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

       ```bash
       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.
  </TabItem>

  <TabItem value="windows">
    <TabItemLabel>
      Windows
    </TabItemLabel>

    1. Open cmd.

    2. Add the environment variables:

       ```bash
       set OS_AUTH_URL=<url>
       set OS_IDENTITY_API_VERSION=3
       set OS_VOLUME_API_VERSION=3
       set CLIFF_FIT_WIDTH=1
       set OS_PROJECT_DOMAIN_NAME=<account_id>
       set OS_PROJECT_ID=<project_id>
       set OS_TENANT_ID=<project_id>
       set OS_TENANT_NAME=<project_name>
       set OS_REGION_NAME=<pool>
       set OS_USER_DOMAIN_NAME=<account_id>
       set OS_USERNAME=<user_name>
       set OS_PASSWORD=<user_password>
       ```

       Specify:

       * `<url>` — the URL (address) for API authorization. The address depends on the region and pool; you can view it in the [list of URLs](/api/urls/);
       * `<account_id>` — account ID. You can view it in the [control panel](https://my.selectel.ru/) in the top right corner;
       * `<project_id>` — project ID. You can copy it in the [control panel](https://my.selectel.ru/vpc/): in the top menu, click **Products** and select **Cloud Servers** → open the projects menu (the name of the current project) → in the project line, click <CopyIcon />;
       * `<project_name>` — project name. You can view it in the [control panel](https://my.selectel.ru/vpc/): in the top menu, click **Products** and select **Cloud Servers** → open the projects menu (the name of the current project) → copy the project name;
       * `<pool>` — [pool](/infrastructure/locations.mdx#pool), for example `ru-2`. You will only be able to manage project infrastructure in this pool;
       * `<user_name>` — the name of the service user you [added in step 2](#add-service-user-for-os);
       * `<user_password>` — service user password. Once the user is created, you cannot view the password — you can only generate a new one. More info in the [Change service user password](/access-control/manage/edit-user-data-or-role.mdx#change-service-user-password) section of the [Change user data and role](/access-control/manage/edit-user-data-or-role.mdx) instruction.

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

       ```bash
       openstack server list
       ```

       If cloud servers are created in the pool and project specified in the variables, they will be listed in the response. If no servers have been created yet, an empty line will be returned.
  </TabItem>
</Tabs>

## Configure OpenStack CLI in a Docker container \{#configure-openstack-in-docker-container}

1. [Install Docker](#install-docker).

2. [Add a service user](#add-service-user-for-docker).

3. [Download the RC file for authorization in OpenStack API](#download-rc-file-for-docker).

4. [Install OpenStack CLI in a Docker container](#install-openstack-in-docker-container).

### 1. Install Docker \{#install-docker}

To install Docker on your local computer, use the [Install Docker](https://docs.docker.com/engine/install/) instructions in the official Docker documentation.

### 2. Add a service user \{#add-service-user-for-docker}

To manage project resources via OpenStack API, [add a service user](/access-control/manage/add-user.mdx#add-service-user) with access in the **Projects** scope and a role:

* `member;`
* or [`reader`](/access-control/role-reference.mdx#reader).

Users can be added by the [Account Owner](/access-control/user-types.mdx#account-owner) or users with the [`iam.admin`](/access-control/role-reference.mdx#iam-admin) role.

### 3. Download the RC file \{#download-rc-file-for-docker}

:::info

Authorization in OpenStack API can only be configured for one [account](/account/), [service user](/access-control/access-management.mdx#roles), [project](/access-control/projects/about-projects.mdx), and [pool](/infrastructure/locations.mdx#pool). If, after authorization, you need to manage resources of another account, in a different project or pool, or under a different service user, you can [change authorization data](/cloud-servers/tools/openstack-cli/change-authorization-data.mdx).

:::

1. In the [control panel](https://my.selectel.ru/iam/service-users), on 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](#add-service-user-for-docker) → **Access** tab.

4. In the **RC files** block:

   4.1. Select a [project](/access-control/projects/about-projects.mdx).

   4.2. Select a [location](/infrastructure/locations.mdx).

   4.3. Click **Download**.

### 4. Install OpenStack CLI in a Docker container \{#install-openstack-in-docker-container}

1. Open the CLI.

2. Create a directory for working with Docker:

   ```bash
   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:

   ```bash
   mv <file_name> <docker_directory>
   ```

   Specify:

   * `<file_name>` — the name of the RC file that you [downloaded in step 3](#download-rc-file-for-docker). The default is `rc.sh`;
   * `<docker_directory>` — the 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:

   ```bash
   nano Dockerfile
   ```

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

   ```bash
   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 while saving changes: press **Ctrl+X**, then **Y+Enter**.

7. Build the Docker container:

   ```bash
   docker build -t osc:dalmatian .
   ```

8. Run the Docker container:

   ```bash
   docker run -ti --rm -v $(pwd):/workspace osc:dalmatian
   ```

9. Go to the `workspace` directory:

   ```bash
   cd /workspace
   ```

10. Apply environment variables from the RC file:

    ```bash
    source <file_name>
    ```

    Specify `<file_name>` — the name of the RC file that you [downloaded in step 3](#download-rc-file-for-docker). The 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](#download-rc-file-for-docker).

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

```bash
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.

<Formbricks />
