Configure OpenStack CLI
You can configure the CLI console client:
Configure OpenStack CLI using the OS
1. Install OpenStack CLI
Ubuntu/Debian
CentOS
macOS
Windows
-
Open the CLI.
-
Install Python 3 and
virtualenv:sudo apt updatesudo apt install python3 virtualenv -
Install
pip3:sudo apt install python3-pip -
Create a virtual environment for working with OpenStack:
virtualenv env -
Activate the virtual environment:
source env/bin/activate -
Install OpenStack CLI in the virtual environment:
pip3 install python-openstackclient -
Verify that OpenStack CLI is installed:
openstack --versionThe OpenStack CLI version number will appear in the response. For example:
openstack 6.1.0 -
Optional: to work with cloud load balancers, install the Octavia component:
pip3 install python-octaviaclient -
Optional: to work with cloud server images, install the Glance component:
pip3 install python-glanceclient -
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.
-
In the control panel, in the top menu, click IAM.
-
Go to the Service users section.
-
Open the page of the service user you added in step 2 → the Access tab.
-
In the RC files block:
4.1. Select a project.
4.2. Select a location.
4.3. Click Download.
4. Configure authorization
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.
Linux/macOS
Windows
-
Open the CLI.
-
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. -
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 isrc.sh. -
Enter the OpenStack password — the password of the service user for whom you downloaded the RC file in step 3.
-
Verify that OpenStack CLI is working. To do this, open the list of cloud servers:
openstack server listIf 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
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
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.
-
In the control panel, in the top menu, click IAM.
-
Go to the Service users section.
-
Open the page of the service user you added in step 2 → the Access tab.
-
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
-
Open the CLI.
-
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. -
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 isrc.sh;<docker_directory>— name of the directory where the RC file will be added and the Dockerfile will be created.
-
Create an empty Dockerfile in this directory using the
nanotext editor:nano Dockerfile -
Add commands for installing OpenStack CLI to the Dockerfile:
FROM alpine:3.17RUN 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/cacheCMD ["sh"] -
Exit the
nanotext editor and save your changes: press Ctrl+X, and then Y+Enter. -
Build the Docker container:
docker build -t osc:dalmatian . -
Run the Docker container:
docker run -ti --rm -v $(pwd):/workspace osc:dalmatian -
Go to the
workspacedirectory:cd /workspace -
Apply environment variables from the RC file:
source <file_name>Specify
<file_name>— name of the RC file you downloaded in step 3. Default isrc.sh. -
Enter the OpenStack password — the password of the service user for whom you downloaded the RC file in step 3.
-
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.