OpenStack CLI
The OpenStack CLI is a console client for working with the OpenStack API. Through the OpenStack CLI in Selectel, you can manage your cloud infrastructure: servers, placement groups, network volumes, networks, images, and load balancers.
Product documentation via the OpenStack CLI can be found under the OpenStack
tab in instructions such as Create cloud server or Connect disk.
The current versions of the components that are supported in Selectel can be viewed in the OpenStack Component Versions table.
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 to authorize to the OpenStack API.
- Configure OpenStack API authorization.
OpenStack component versions
Install OpenStack CLI
- Ubuntu, Debian
- CentOS
- macOS
- Windows
-
Open the CLI.
-
Install the OpenStack CLI:
sudo apt update
sudo apt install python3-openstackclient -
Verify that the OpenStack CLI is installed:
openstack --version
The version number will appear in the response.
-
Optional: Install additional packages for OpenStack components:
apt install python3-<compoment>client
Specify
<compoment>
is the name of the component:octavia
— to work with load balancers;glance
is for working with images.
-
Open the CLI.
-
Install pip for Python3:
sudo yum update
sudo yum 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 additional packages for OpenStack components:
apt install python3-<compoment>client
Specify
<compoment>
is the name of the component:octavia
— to work with load balancers;glance
is for working with images.
-
Open the CLI.
-
Install Python3:
brew install python
-
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 additional packages for OpenStack components:
apt install python3-<compoment>client
Specify
<compoment>
is the name of the component:octavia
— to work with load balancers;glance
is for working with images.
-
Download and install Python, such as 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, under Workloads in the Desktop & Mobile block, check the Desktop development with C++ checkbox.
-
Open cmd.
-
Install the OpenStack CLI:
pip install -U buildtools
pip install python-openstackclient -
Verify that the OpenStack CLI is installed:
openstack --version
The version number will appear in the response.
-
Optional: Install additional packages for OpenStack components:
pip install python-<compoment>client
Specify
<compoment>
is the name of the component:octavia
— to work with load balancers;glance
is for working with images.
Create a service user
To authorize in the OpenStack API, you need to create a service user with the role Project Administrator or Project Viewer and add it to cloud platform project.
-
From the control panel in the upper right corner, open the menu (account number) and select Profile & Settings.
-
Go to User Management.
-
Click Add User.
-
Select the Service User type.
-
Enter a username. It will be used during 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 only be configured for a single service user, cloud platform project, and pool. If necessary, you can change the authorization data.
- Ubuntu, Debian, CentOS, macOS
- Windows
- Docker
-
In Control Panel, go to Cloud Platform → Access.
-
Open the External Access tab.
-
Select created service user with the role of Project Administrator or Project Supervisor.
-
Select pool. Only this pool will be able to manage the infrastructure of the project.
-
Click Download.
-
On the local system, navigate to the directory with the downloaded RC file:
cd <directory_name>
Specify
<directory_name>
— the name of the directory with the RC file. -
Run the script from the RC file:
source <file_name.sh>
Specify
<file_name.sh>
is the name of the RC file, the default isrc.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 that are specified in the RC file, a list of them will appear in the command output. If no servers have been created yet, the output of the command will be an empty string.
-
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 theset
command, if in PowerShell useenv
;OS_AUTH_URL
— the address (URL) is region and pool dependent, can be viewed in the URL list;<account_id>
— control panel account number. You can look in control panel in the upper right corner;<project_id>
— cloud platform project ID. In Control Panel, go to Cloud Platform → open the projects menu (name of the current project) → in the row of the desired project, click ;<project_name>
is the name of the cloud platform project. Can be viewed in dashboard under Cloud Platform → projects menu;<pool>
— pool, such asru-2
. Only this pool will be able to manage the infrastructure of the project;<user_name>
is the name of the created service user with the Project Administrator or Project Watcher role;<user_password>
— service user password.
-
Test the OpenStack CLI, for example, by opening the list of cloud servers:
openstack server list
If cloud servers have been created in the pool and project that are specified in the RC file, a list of them will appear in the command output. If no servers have been created yet, the output of the command will be an empty string.
You can use a Docker container to work with the OpenStack CLI.
-
In Control Panel, go to Cloud Platform → Access.
-
Open the External Access tab.
-
Select created service user with the role of Project Administrator or Project Supervisor.
-
Select pool. Only this pool will be able to manage the infrastructure of the project.
-
Click Download.
-
On the local system, install Docker. For more information, see the Install Docker instructions in the Docker documentation.
-
Open the CLI.
-
Create a directory to work with Docker:
mkdir <docker_directory>
Specify
<docker_directory>
— the 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>
as the name of the 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/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
-
Navigate to the
workspace
directory:cd workspace
-
Run the script from the RC file:
source <file_name.sh>
Specify
<file_name.sh>
, which is the name of the RC file you moved to the directory with the Dockerfile in step 9. -
Test the OpenStack CLI, for example, by opening the list of cloud servers:
openstack server list
If cloud servers have been created in the pool and project that are specified in the RC file, a list of them will appear in the command output. If no servers have been created yet, the output of the command will be an empty string.
Change authorization data
To change the authorization details:
- set new values for the 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, use the
--os-region-name
key to change the pool. A list of all options and examples can be found in the Options section of the OpenStack documentation.