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
Configure OpenStack CLI using OS tools
1. Install the OpenStack CLI
Ubuntu/Debian
CentOS
macOS
Windows
-
Open the CLI.
-
Install Python 3 and virtualenv:
sudo apt update
sudo apt install python3 virtualenv -
Install pip3:
sudo apt install python3-pip
-
Create a virtual environment to work with OpenStack:
virtualenv env
-
Activate the virtual environment:
source env/bin/activate
-
Install the OpenStack CLI in a virtualized environment:
pip3 install python-openstackclient
-
Verify that the OpenStack CLI is installed:
openstack --version
The version number will appear in the response.
-
Optional: install the Octavia component to work with cloud load balancers:
pip3 install python-octaviaclient
-
Optional: install the Glance component to work with images:
pip3 install python-glanceclient
-
Open the CLI.
-
Install Python 3, virtualenv, and pip3:
sudo dnf update -y
sudo dnf install python3 -y
sudo dnf install virtualenv -y
sudo dnf install python3-pip -y -
Install the OpenStack CLI:
pip3 install python-openstackclient
-
Verify that the OpenStack CLI is installed:
openstack --version
The version number will appear in the response.
-
Optional: install the Octavia component to work with cloud load balancers:
pip3 install python-octaviaclient
-
Optional: install the Glance component to work with images:
pip3 install python-glanceclient
-
Open the CLI.
-
Install Python 3 and pip3:
brew install python3
-
Install virtualenv:
pip3 install virtualenv
-
Install the OpenStack CLI:
brew install openstackclient
-
Verify that the OpenStack CLI is installed:
openstack --version
The version number will appear in the response.
-
Optional: install the Octavia component to work with cloud load balancers:
pip3 install python-octaviaclient
-
Optional: install the Glance component to work with images:
pip3 install python-glanceclient
-
Download and install Python, for example, version Python 3.12.0. When running the installation, check the Add python.exe to PATH checkbox.
-
Download and install Microsoft C++ Build Tools. When starting the installation, in the Workloads section of the Desktop & Mobile block, check the Desktop development with C++ checkbox.
-
Open the CLI.
-
Install the OpenStack CLI:
pip3 install python-openstackclient
-
Verify that the OpenStack CLI is installed:
openstack --version
The version number will appear in the response.
-
Optional: install the Octavia component to work with cloud load balancers:
pip3 install python-octaviaclient
-
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.
-
In the control panel, click Account.
-
Go to the Service Users section.
-
Click Add User.
-
Select the Service User type.
-
Enter a user name. This will be used for authorization.
-
Enter a password for the user or generate one.
-
Save password — once a user is created, you cannot view the password, only change it.
-
Select a user role:
- Project administrator — can create, edit and delete project resources;
- Project Observer — can view project resources.
-
Check the projects to which you want to add the user.
-
Click Add User.
3. Download RC file
To set up authorization, you need to download the service user RC file.
-
In the control panel, on the top menu, click Account.
-
Go to the Service Users section.
-
Open the page of the service user you added to work with the OpenStack CLI → Access tab.
-
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
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.
Linux/macOS
Windows
-
Open the CLI.
-
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. -
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 defaultis rc.sh
. -
Enter the OpenStack password — the password of the service user for which the RC file was created.
-
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.
-
Open the CLI.
-
Add environment variables:
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>
— address (URL) for authorization in the API. The URL depends on the region and pool, and can be viewed in the URL list;<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 project line, click ;<project_name>
— project name. You can view it in control panel: in the top menu, click Products and select Cloud Servers → open the project menu (name of the current project) → copy the project name;<pool>
— pool for exampleru-2
. It will be possible to manage the project infrastructure only in this pool;<user_name>
— the name of the service user you added to work in the OpenStack CLI at step 10;<user_password>
— service user password. After creating a user, you cannot view the password — you can only generate a new one. More details in the subsection Change service user password instructions Change user data and role.
-
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.
Configure OpenStack CLI in a Docker container
-
Add a service user to manage resources through the OpenStack API.
-
Download the RC file for authorization to the OpenStack API.
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.
-
In the control panel, on the top menu, click Account.
-
Go to the Service Users section
-
Click Add Service User.
-
Enter a user name. This will be used for authorization.
-
Enter a password for the user or generate one.
-
Save password — once a user is created, you cannot view the password, only change it.
-
Select a user role:
- Project administrator — can create, edit and delete project resources;
- Project Observer — can view project resources.
-
Check the projects to which you want to add the user.
-
Click Add User.
3. Download RC-file for authorization
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.
-
In the control panel, click Account.
-
Go to the Service Users section.
-
Open the page of the service user you added to work with the OpenStack CLI → Access tab.
-
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
-
Open the CLI.
-
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. -
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.
-
Create an empty Dockerfile in this directory:
nano Dockerfile
-
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"] -
Exit the
nano
text editor with your changes saved: press Ctrl+X and then Y+Enter. -
Build a Docker container:
docker build -t osc:dalmatian .
-
Start the Docker container:
docker run -ti --rm -v $(pwd):/workspace osc:dalmatian
-
Navigate to the
workspace
directory:cd /workspace
-
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 isrc.sh
-
Enter the OpenStack password — the password of the service user for which you downloaded the RC file in step 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 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:
- if you configured authorization using the operating system — run the OpenStack CLI in the operating system;
- if you configured authorization in the Docker container — run the OpenStack CLI in the Docker container.
Start the OpenStack CLI in the OS
Linux/macOS
Windows
-
Open the CLI.
-
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 isrc.sh
-
Enter the OpenStack password — the password of the service user for which you downloaded the RC file in step 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.
-
Open the CLI.
-
Add environment variables:
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>
— address (URL) for authorization in the API. The URL depends on the region and pool, and can be viewed in the URL list;<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 project line, click ;<project_name>
— project name. You can view it in control panel: in the top menu, click Products and select Cloud Servers → open the project menu (name of the current project) → copy the project name;<pool>
— pool for exampleru-2
. It will be possible to manage the project infrastructure only in this pool;<user_name>
— the name of the service user you added to work in the OpenStack CLI at step 10;<user_password>
— service user password. After creating a user, you cannot view the password — you can only generate a new one. More details in the subsection Change service user password instructions Change user data and role.
-
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
-
Open the CLI.
-
Start the Docker container:
docker run -ti --rm -v $(pwd):/workspace osc:dalmatian
-
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 defaultis rc.sh
. -
Enter the OpenStack password — the password of the service user for which you downloaded the RC file in step 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.
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:
- if you configured authorization using the operating system — change the authorization data in the OS;
- if you configured authorization in the Docker container — change the authorization data in the Docker container.
Change authorization data in the OS
Linux/macOS
Windows
-
Open the CLI.
-
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 defaultrc.sh
-
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 exampleru-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.
-
Exit the
nano
text editor with your changes saved: press Ctrl+X and then Y+Enter. -
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 isrc.sh
-
Enter the OpenStack password — the password of the service user for which you downloaded the RC file in step 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.
-
Open the CLI.
-
Add environment variables:
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>
— address (URL) for authorization in the API. The URL depends on the region and pool, and can be viewed in the URL list;<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 ;<project_name>
— project name. You can view it in control panel: in the top menu, click Products and select Cloud Servers → open the project menu (name of the current project);<pool>
— pool for exampleru-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;<user_password>
— service user password. After creating a user, you cannot view the password — you can only generate a new one. More details in the subsection Change service user password instructions Change user data and role.
-
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
-
Open the CLI.
-
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 defaultrc.sh
-
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 exampleru-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.
-
Exit the
nano
text editor with your changes saved: press Ctrl+X and then Y+Enter. -
Start the Docker container:
docker run -ti --rm -v $(pwd):/workspace osc:dalmatian
-
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 defaultis rc.sh
. -
Enter the OpenStack password — the password of the service user for which the RC file was created.
-
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.