OpenStack CLI
OpenStack CLI is a console client for working with the OpenStack API. You can manage your cloud infrastructure in Selectel through the OpenStack CLI: servers, placement groups, network volumes, networks, images and load balancers.
Documentation on working with products through the OpenStack CLI can be found on the tab OpenStack
In the instructions, for example, Create a cloud server or Attach the volume.
The current versions of the components that are supported in Selectel can be viewed in the table below OpenStack component versions.
The OpenStack CLI can be installed on your local system.
- Install the OpenStack CLI and additional packages. If you want to use a Docker container to work with the OpenStack CLI, you do not need to perform this step.
- Create a service user for authorization in the OpenStack API.
- Configure authorization in the OpenStack API.
OpenStack component versions
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 load balancers — Yoga release version 3.4.0 is required for compatibility with the Yoga release version:
pip3 install python-octaviaclient===3.4.0
-
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 Octavia component to work with cloud load balancers — Yoga release version 3.4.0 is required for compatibility with the Yoga release version:
pip3 install python-octaviaclient===3.4.0
-
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 Octavia component to work with cloud load balancers — Yoga release version 3.4.0 is required for compatibility with the Yoga release version:
pip3 install python-octaviaclient===3.4.0
-
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 cmd.
-
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 load balancers — Yoga release version 3.4.0 is required for compatibility with the Yoga release version:
pip3 install python-octaviaclient===3.4.0
-
Optional: install the Glance component to work with the images:
pip3 install python-glanceclient
Create a service user
To authorize in OpenStack API you need to create service user with the role Project Administrator or Project Supervisor and add it to the project.
-
In the control panel go to Access control → User management.
-
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 viewer — can view project resources.
-
Check the projects to which you want to add the user.
-
Click Add user.
Set up authorization
To authorize in the OpenStack API, you need to add environment variables. In Unix systems (Ubuntu, Debian, CentOS, and macOS), you need to run a script from an RC file that can be downloaded from the control panel; in Windows, you need to add variables manually.
Authorization in the OpenStack API can be configured for only one service user, projects and pool. If necessary, you can change the authorization data.
Ubuntu, Debian, CentOS, macOS
Windows
Docker
-
In the control panel go to Cloud platform → Access.
-
Open the tab External access.
-
Select created service user with the role of Project Administrator or Project viewer.
-
Select pool. Only this pool will be able to manage the project infrastructure.
-
Click Download.
-
On the local system, navigate to the directory with the downloaded RC file:
cd <directory_name>
Specify
<directory_name>
— name of the directory with the RC file. -
Run the script from the RC file:
source <file_name.sh>
Specify
<file_name.sh>
— RC file name, defaultrc.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 cmd or PowerShell.
-
Add environment variables:
<set> OS_AUTH_URL=https://cloud.api.selcloud.ru/identity/v3
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:
<set>
— command to add environment variables. If you are working in cmd, use the commandset
if PowerShell —env
;OS_AUTH_URL
— address (URL) depends on the region and pool, you can look in the URL list;<account_id>
— control panel account number. You can look in control panel in the upper right-hand corner;<project_id>
— Project ID. In the control panel go to Cloud platform → 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 panel under Cloud platform → project menu;<pool>
— pool for exampleru-2
. Only this pool will be able to manage the project infrastructure;<user_name>
— name created service user with the role of project administrator or project viewer.;<user_password>
— the service user's password.
-
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.
You can use a Docker container to work with the OpenStack CLI.
-
In the control panel go to Cloud platform → Access.
-
Open the tab External access.
-
Select created service user with the role of Project administrator or Project viewer.
-
Select pool. Only this pool will be able to manage the project infrastructure.
-
Click Download.
-
On your local system, install Docker. More details in the instructions Install Docker in the Docker documentation.
-
Open the CLI.
-
Create a directory to work with Docker:
mkdir <docker_directory>
Specify
<docker_directory>
— name of the directory where the Dockerfile will be created. -
Move the RC file you downloaded in step 5 to the directory with the Dockerfile.
-
Create an empty file for the Dockerfile in this directory:
nano <dockerfile_name>
Specify
<dockerfile_name>
— Dockerfile name. -
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/2023.1 \
git+https://github.com/openstack/python-glanceclient.git@stable/2023.1 \
git+https://github.com/openstack/python-octaviaclient.git@stable/2023.1 \
&& apk del build-base linux-headers python3-dev libffi-dev openssl-dev git cargo iputils curl && rm -rf /var/cache
CMD ["sh"] -
Build a Docker container:
docker build -t osc:antelope .
-
Start the Docker container:
docker run -ti --rm -v $(pwd):/workspace osc:antelope
-
Go to the directory
workspace
:cd workspace
-
Run the script from the RC file:
source <file_name.sh>
Specify
<file_name.sh>
— name of the RC file that you moved to the directory with the Dockerfile in step 9. -
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.
Change authorization data
To change your authorization details:
- set new values for environment variables. For Ubuntu, Debian, CentOS and macOS, change the variables in the RC file; for Windows, set the values directly;
- pass the new values in OpenStack CLI commands with keys. For example, to change the pool, use the key
--os-region-name
. A list of all options and examples can be found in the section Options OpenStack documentation.