How to install and configure OpenStack Client on Linux

The OpenStack client is a command-line tool for OpenStack that integrates command sets with Compute, Identity, Image, Object Storage, and Block Storage APIs into a single shell with a unified command structure. The OpenStack client enables you to interact with OpenStack services over the network through API calls.

A prerequisite for this setup is a working OpenStack Cloud platform. You can check out our OpenStack guide to learn how to write articles. If you are a developer and want to contribute, the code will be hosted on OpenStack’s Git server.

Step 1: Install the Python Pip tool

Some Linux distributions include packaged versions of the OpenStack command line client, you can install these versions directly, but we will install from Pip. Install pip for your system via the package manager:

------------ Install pip on Debian / Ubuntu ----------
$ sudo apt-get -y update
$ sudo apt-get -y install python-dev python-pip
$ sudo pip install --upgrade pip

------------ Install pip on CentOS / RHEL ----------
$ sudo yum -y install python-devel python-pip
$ sudo pip install --upgrade pip

------------ Install pip on Arch / Manjaro ----------
$ sudo pacman -Syy
$ sudo pacman -S python-pip
$ sudo pip install --upgrade pip

--------- Install pip on macOS ----------------
$ sudo easy_install pip

Confirm that the pip version is installed.

$ pip --version
pip 19.1.1 from /usr/lib/python3.7/site-packages/pip (python 3.7)

Step 2: Install OpenStack Client on Linux

After installing Pip, continue to install the OpenStack command line client.

sudo pip install python-openstackclient

Show more information about the installed Openstack command line client.

$ pip show python-openstackclient
Name: python-openstackclient
Version: 3.19.0
Summary: OpenStack Command-line Client
Author: OpenStack
Author-email: [email protected]
License: UNKNOWN
Location: /usr/lib/python3.7/site-packages
Requires: python-cinderclient, cliff, python-keystoneclient, keystoneauth1, python-novaclient, six, openstacksdk, oslo.i18n, python-glanceclient, osc-lib, pbr, Babel, oslo.utils

You should have Open stack Enter the command in PATH.

$ which openstack

Step 3: Configure the OpenStack client on Linux

You can extract the OpenStack configuration file from OpenStack Director, and if you have the correct access credentials, you can create one.

$ nano ~/.keystonerc
    export OS_USERNAME='admin'
    export OS_PASSWORD='adminpassword'
    export OS_AUTH_URL=
    export PS1='[[email protected]h W(keystone_admin)]$ '
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default

Update the variables to match your OpenStack environment. Once done, get the files to start managing OpenStack Cloud using the openstack command line tool.

$ source ~/.keystonerc

Your shell prompt should be changed to.

[[email protected]h W(keystone_admin)]$ 

Run the openstack command to confirm that it is working.

[[email protected]h W(keystone_admin)]$ openstack network list
| ID                                   | Name                      | Subnets                                                                    |
| 900b1ede-3e62-4d73-88d3-b28c129a6bb6 | public                    | c1770934-54bb-4252-928a-c7a41c6e114a                                       |
| da22131e-0b50-46e7-8d35-b18bbb161f1b | mycluster-lww6p-openshift | 6770ab86-2481-46e6-8d29-ab3c6a82b6cc, ec91b5c4-37fd-453f-be02-9ee8327654c2 |
| e406e76f-e89d-42a2-bab1-9c883b2e49aa | private                   | 76ff61dd-0438-4848-a611-f4b4de070164                                       |

$ openstack image list
| ID                                   | Name                | Status |
| 0850ee38-1bdf-4379-9c69-0cf73e8b7c65 | Arch-Linux-x86_64   | active |
| e98445b6-f14f-488c-a18a-1f66c6de15c7 | CentOS-7-x86_64     | active |
| 7b4b616e-71f3-4419-9777-7aee66fad62c | Cirros-0.4.0-x86_64 | active |
| 8514fea0-3d55-4248-a79f-5c0183f95898 | CoreOS-x86_64       | active |
| 98bbd9e6-abbc-45fa-ac95-b91b7b18ba0a | Debian-9-amd64      | active |
| 113b90b6-4e1e-4715-b9ab-456c191a82b3 | Fedora-30-x86_64    | active |
| 06c17e8a-0d4c-428a-89b5-b0eb2489f403 | Ubuntu-16.04-x86_64 | active |
| 2ba79fa6-2434-4dc6-ad86-0baf29d44c79 | rhcos               | active |
| c3bb11c7-81af-49fe-a26c-a60e9b14585c | rhcos-kvm           | active |

Step 4: Enable OpenStack Bash to complete

Use the openstack complete command to generate a bash completion script.

openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion > /dev/null

Sign out

$ logout
$ exit

Then log in again to enjoy the completion of OpenStack bash.

$ openstack network 
agent     create    flavor    log       meter     rbac      service   show      trunk     
auto      delete    list      loggable  qos       segment   set       subport   unset    

You have learned how to install and configure the OpenStack client on a Linux system.

Other interesting articles:

Top open source cloud platforms and solutions

The best Linux books for beginners and experts

Adding images to Glance using the OpenStack command line