How to install OpenStackClient for Linux on CloudFerro Cloud

The OpenStack CLI client allows you to manage OpenStack environments using the command line interface. Its functions include:

  • Creating, starting, shutting down, shelving, deleting, rebooting virtual machines

  • Assigning a floating IP to your virtual machine

  • Listing available resources, including volumes, virtual machines and floating IPs

You can also automate these operations using scripts.

This article covers two methods of installing this piece of software on Ubuntu. The first method should be more convenient and sufficient for most needs. The second method is for advanced use cases, such as:

  • keeping multiple versions of the OpenStack CLI client ready to use on the same computer or

  • needing more advanced features than what Ubuntu packages provide and

  • having to use the OpenStack CLI client on a Linux distribution which does not support the installation method described in the first method.

Prerequisites

No. 1 Hosting

You need a CloudFerro Cloud hosting account with Horizon interface https://horizon.cloudferro.com.

No. 2 Linux installed on your computer

You need to have Linux installed on your local computer or a virtual machine. This article was written for Ubuntu 22.04 LTS and Python 3. Instructions for other Linux distributions might be different.

If you choose a virtual machine, you can run it yourself, or it can be, say, a virtual machine running on CloudFerro Cloud cloud. If you choose this latter option, the following articles might be of help for you:

What Are We Going To Do

  • Install the OpenStack CLI client using the apt package manager or pip

  • Verify whether installation was successful

Step 1: Install the OpenStack CLI client

Method 1: Using Ubuntu package manager

Update Ubuntu software with the following command:

sudo apt update && sudo apt upgrade

Reboot if required.

Once the packages are updated, install openstack command from package python3-openstackclient:

sudo apt install python3-openstackclient

Method 2: Using pip and Python virtual environment

Create a virtual environment and activate it

Open the terminal of the operating on system on which you wish to install the OpenStack CLI client.

Update system packages to the latest version:

sudo apt update && sudo apt upgrade

Install latest python client:

sudo apt install python3-dev

Install the package used to create Python virtual environments. If Python is not installed, the command below should pull it as a dependency.

sudo apt install python3-venv

You will now create virtual environment, which actually is a folder into which Python will keep all of its files. You can have as many such environments as you like and in use it looks like you have multiple “instances” of Python, each environment with a separate set of libraries and code. The OpenStack CLI client will be in installed in one of such environment and for the purposes of this article, let its name be openstack_cli.

Create a new virtual environment called openstack_cli as follows:

python3 -m venv openstack_cli

Without leaving the previous folder, activate the environment:

source openstack_cli/bin/activate

Important

In the future, each time you start the terminal, if you want to use the OpenStack CLI client, you will need to reenter the appropriate virtual environment as described above.

After that, the prompt will show (openstack_cli) in prefix:

../_images/activate_environment.png

Install openstackclient

Before installing the OpenStack CLI client, you should upgrade pip (the package installer for Python) to the latest version, using the command below:

pip install --upgrade pip
../_images/install_new_pip.png

Install the python-openstackclient package containing the OpenStack CLI client:

pip install python-openstackclient

This should also install the openstack command which allows you to interact with the OpenStack CLI client.

You can use multiple virtual environments to store different versions of the OpenStack CLI client if that is what you need.

Step 2: Verify whether installation was successful

Here is how you can verify that the openstack was installed properly, regardless of the way it was installed. The idea is to use the built-in –help option that OpenStack CLI client has. If you can view openstack help screen, the installation was successful.

Important

If you are using the OpenStack CLI client from the virtual environment (and not its apt package), make sure that your current terminal session has entered that environment before executing the openstack command.

Execute the following command:

openstack --help

You should see information regarding using of the OpenStack CLI command. The beginning of this output should look like this:

../_images/openstack_cli_install_linux_help.png

If this command shows its output using a pager, you should be able use the arrows (or vim keys - letters j and k on your keyboard) to scroll the text and q to exit.

If you are able to read the help of the OpenStack CLI client this way, the installation should be successful.

What To Do Next

Authenticate before using openstack commands

In order to use the CLI client to perform operations on your CloudFerro Cloud cloud environment, you need to authenticate to your account. See

How to activate OpenStack CLI access to CloudFerro Cloud cloud using one- or two-factor authentication

If you successfully authenticate, you will be able to execute command such as

openstack flavor list

which will list flavors in your project. The output might look like this:

../_images/openstackcli_flavor_list.png

Installation of additional OpenStack clients

The package you installed by following this article provides you with the basic OpenStack commands. If you want to use additional features in CLI (such as managing load balancers or using DNS as a service), you will need additional packages. Depending on the method you used to install the OpenStack CLI client, see one of the tabs below:

On official Ubuntu apt repository, their names usually follow this syntax:

python3-<project>client

in which <project> is the name of the project, like octavia or designate.

The following command will install some commonly used packages:

sudo apt install python3-manilaclient python3-octaviaclient python3-designateclient python3-barbicanclient python3-heatclient python3-magnumclient python3-novaclient python3-swiftclient python3-glanceclient python3-cinderclient python3-novaclient

Describing each of the clients is beyond the scope of this article.

Installation on Windows

You can also install OpenStack CLI client on Windows, using GitBash or Linux on WSL: