OpenStack CLI
The OpenStack CLI is a console client for working with the OpenStack API that is installed on the local computer. You can manage your cloud infrastructure in Selectel through the OpenStack CLI: servers, placement groups, network volumes, networks, images, load balancers.
The current versions of the components that are supported in Selectel can be viewed in the table below OpenStack component versions.
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:
sudo apt update
sudo apt install python3 -
Install pip3:
sudo apt install python3-pip
-
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 Octavia component to work with cloud-based load balancers:
pip3 install python-octaviaclient
-
Optional: install the Glance component to work with the images:
pip3 install python-glanceclient
-
Open the CLI.
-
Install Python 3:
sudo dnf update -y
sudo dnf install python3 -y -
Install pip3:
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 the cloud-based load balancers:
pip3 install python-octaviaclient
-
Optional: install the Glance component to work with the images:
pip3 install python-glanceclient
-
Open the CLI.
-
Install Python 3 and pip3:
brew install python3
-
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 the cloud-based load balancers:
pip3 install python-octaviaclient
-
Optional: install the Glance component to work with the images:
pip3 install python-glanceclient
-
Download and install Python, for example, Python 3.12.0. Check the checkbox when starting the installation Add python.exe to PATH.
-
Download and install Microsoft C++ Build Tools. When starting the installation in the Workloads en bloc Desktop & Mobile check the box Desktop development with C++.
-
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 Octavia component to work with cloud-based load balancers:
pip3 install python-octaviaclient
-
Optional: install the Glance component to work with the images:
pip3 install python-glanceclient
2. Add a service user
To manage resources through the OpenStack API, you need to create a service user with the role of Project Administrator or Project Supervisor and add it to the project. If after authorization you need to manage resources under another service user, you can change the authorization data.
-
В control panels click Account.
-
Go to the section Users.
-
Click Add user.
-
Select type 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 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.
-
В control panels from the top menu, press Account.
-
Go to the section Users → tab Service users.
-
Open the page of the service user you added the OpenStack CLI for working with OpenStack → tab Access.
-
In the block RC files:
4.1 Select project.
4.2 Select region.
4.3. Select pool.
4.4. Press Download.
4. Set up authorization
Authorization in the OpenStack API can be configured for only one account, service user, projects и pool. If, after authorization, you need to manage the resources of another account, in another project or pool, or under a different service user, you can change the authorization data.
Linux/macOS
Windows
-
Open the CLI.
-
Navigate to the directory with the RC file you got when you downloading RC file for authorization in step 4.4:
cd <directory_name>
Specify
<directory_name>
— name of the directory with the RC file. -
Run the script from the RC file:
source <rcfile_name.sh>
Specify
<rcfile_name.sh>
— RC file name, defaultrc.sh
. -
Enter the OpenStack password — the password of the service user for which the RC file was created.
-
Check the OpenStack CLI operation, for example, 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, 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, it can be viewed in the URL list;<account_id>
— control panel account number. You can look in control panels in the upper right-hand corner;<project_id>
— Project ID. Can be copied to control panels: from the top menu, press Products and select Cloud servers → open the project menu (name of the current project) → in the project line press ;<project_name>
— project name. You can look in control panels: from the top menu, press Products and select Cloud servers → open the project menu (name of the current project) → copy the project name;<pool>
— pool for exampleru-2
. Only this pool will be able to manage the project infrastructure;<user_name>
— the name of the service user you added to work in the OpenStack CLI at step 10;<user_password>
— service user password.
-
Check the OpenStack CLI operation, for example, open the list of cloud servers:
openstack server list
If cloud servers have been created in the pool and project specified in the variables, their list will appear in the command output. 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 in the OpenStack API.
1. Install Docker
On your local computer, install Docker. Use the instructions Install Docker in the Docker documentation.
2. Add a service user
To manage resources through the OpenStack API, you need to create a service user with the role of Project Administrator or Project Supervisor and add it to the project. If after authorization you need to manage resources under another service user, you can change the authorization data.
-
В control panels from the top menu, press Account.
-
Go to the section Users
-
Click Add user.
-
Select type 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 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 one only account, service user, projects и pool. If, after authorization, you need to manage the resources of another account, in another project or pool, or under a different service user, you will be able to change the authorization data.
-
В control panels click Account.
-
Go to the section Users → tab Service users.
-
Open the page of the service user you added for working with OpenStack CLI → tab Access.
-
In the block RC files:
4.1 Select project.
4.2 Select region.
4.3. Select pool.
4.4. Press 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>
— name of the directory where the RC file will be added and the Dockerfile will be created. -
Move the RC file that you received with the downloading RC file for authorization in step 4.4 to the directory:
mv <rcfile_name.sh> <docker_directory>
Specify:
<rcfile_name.sh>
— the name of the RC file you received when downloading RC file for authorization in step 4.4. By defaultrc.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 \
&& apk del build-base linux-headers python3-dev libffi-dev openssl-dev git cargo iputils curl && rm -rf /var/cache
CMD ["sh"] -
Exit the text editor
nano
while saving changes: press Ctrl+Xand 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
-
Go to the directory
workspace
:cd /workspace
-
Run the script from the RC file:
source <rcfile_name.sh>
Specify
<rcfile_name.sh>
— the name of the RC file you received when downloading RC file for authorization in step 4.4 and moved it to the directory with the Dockerfile. By defaultrc.sh
-
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.
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's tools — change the authorization data in the OS;
- if you've configured authorization in a 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 a text editor
nano
:nano /<directory_name>/<rcfile_name.sh>
Specify:
<directory_name>
— the name of the directory with the RC file and Dockerfile;<rcfile_name.sh>
— the name of the RC file you received when downloading RC file for authorization in step 4.4. By 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. You can look in control panels in the upper right hand corner;<project_id>
— Project ID. Can be copied to control panels: from the top menu, press Products and select Cloud servers → open the project menu (name of the current project) → in the line of the desired project, click ;<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 → Users → tab Service users.
-
Exit the text editor
nano
while saving changes: press Ctrl+Xand then Y+Enter. -
Run the script from the RC file:
source <rcfile_name.sh>
Specify
<rcfile_name.sh>
— the name of the RC file you received when downloading RC file for authorization in step 4.4. By defaultrc.sh
-
Enter the OpenStack password, which is the password for the service user for which you are downloaded the RC file in step 4.4.
-
Check the OpenStack CLI operation, for example, open the list of cloud servers:
openstack server list
If cloud servers have been created in the pool and project specified in the variables, 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, it can be viewed in the URL list;<account_id>
— control panel account number. You can look in control panels in the upper right hand corner;<project_id>
— Project ID. Can be copied to control panels: from the top menu, press Products and select Cloud servers → open the project menu (name of the current project) → in the line of the desired project, click ;<project_name>
— project name. You can look in control panels: from the top menu, press 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 → Users → tab Service users;<user_password>
— service user password.
-
Check the OpenStack CLI operation, for example, open the list of cloud servers:
openstack server list
If cloud servers have been created in the pool and project specified in the variables, their list will appear in the command output. 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 a text editor
nano
:nano /<docker_directory>/<rcfile_name.sh>
Specify:
<docker_directory>
— name of the directory with the added RC file and Dockerfile;<rcfile_name.sh>
— the name of the RC file you received when downloading RC file for authorization in step 4.4. By 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. You can look in control panels in the upper right hand corner;<project_id>
— Project ID. Can be copied to control panels: from the top menu, press Products and select Cloud servers → open the project menu (name of the current project) → in the line of the desired project, click ;<pool>
— pool for exampleru-2
;<user_name>
— the name of the service user you added to manage resources through the OpenStack CLI. You can look at control panels: from the top menu, press Account → Users → tab Service users.
-
Exit the text editor
nano
while saving changes: press Ctrl+Xand then Y+Enter. -
Start the Docker container:
docker run -ti --rm -v $(pwd):/workspace osc:dalmatian
-
Run the script from the RC file:
source <rcfile_name.sh>
Specify
<rcfile_name.sh>
— the name of the RC file you received when downloading RC file for authorization in step 4.4. By defaultrc.sh
. -
Enter the OpenStack password — the password of the service user for which the RC file was created.
-
Check the OpenStack CLI operation, for example, open the list of cloud servers:
openstack server list
If cloud servers have been created in the pool and project specified in the variables, their list will appear in the command output. If no servers have been created yet, the command output will be empty.