In the previous chapter we took a look at using OpenStack through the dashboard. Let's try to follow the same steps now, but through the use of the CLI.
CLI Overview
In the most recent versions, OpenStackClient project provides a unified command-line client, which enables you to access the project API through easy-to-use commands, although the commands for each single service still remain valid (for example, the Compute service provides a nova
command-line client). Anyway, you can use the unified openstack
command for the most of OpenStack services. Internally, each command uses cURL command-line tools, which embed API requests. OpenStack APIs are RESTful APIs, and use the HTTP protocol. For more information, see OpenStackClient document.
Install the OpenStack client
The first step is to install the client on your VM. Below is an example of installation on CentOS7, but for more details, refer to the official documentation.
# Install the prerequisite software $ sudo yum install python3 python3-devel python3-pip python3-setuptools $ sudo pip3 install --upgrade setuptools $ sudo pip3 install --upgrade pip # Install the OpenStack client $ pip3 install python-openstackclient # Verify correct installation $ openstack --version openstack 5.7.0
Application Credentials
Once the client has been downloaded, we need to download the login credentials from OpenStack. Let's connect to the dashboard and click on the tab Identity
-> Application Credentials
. Create an application credential
, assigning a name and an expiration date, and download the generated openrc
file. Upload it to your VM and, before launching any OpenStack client command, execute the command source <openrc-file>
.
The source
command will have to be re-executed at each new access on the VM.