Getting started with the OpenStack command line client

Overview

OpenStack is open-source software that allows you to create private and public clouds. A command line tool is available which makes it easy to work with. This article explains how to install this client on your cloud server.

Installation

The OpenStack command line client can be installed in several ways. This article shows how to install it using pip in a virtualenv as well as installing globally.

Install python-dev

Install python-dev so you can build Python extensions. This is necessary to install the openstackclient using pip.

If you're using Python 2:

[user@localhost]$ sudo apt-get install python2.7-dev

If you're using Python 3:

[user@localhost]$sudo apt-get install python3-dev

Install pip

First, run the following to see if 'pip' is installed:

If you're running Python 2

[user@localhost]$pip -V

If you're running Python 3

[user@localhost]$pip3 -V

If it's not, install with the following:

If you're running Python 2

[user@localhost]$ sudo apt-get install python-pip

If you're running Python 3

[user@localhost]$ sudo apt-get install python3-pip

Install virtualenv

One way to install the OpenStack CLI is in a virtual environment. Now that pip is installed, run the following to install virtualenv:

[user@localhost]$sudo apt-get install python-virtualenv

Install OpenStack CLI

Installing within a virtualenv

This is a safe method as your installation is housed within a virtual environment and does not touch anything else in your system. To do this, create a virtual environment, activate it, and install the OpenStack CLI within it.

If you're using Python 2, run the command pip. If you're using Python 3, run the command pip3.

This installs the client in a virtual environment separated from the rest of your system. In order to be able to use the client you will have to activate the virtual environment using the source command above.

Installing globally

You can also install on your system globally using pip for Python 2.

[user@localhost]$ sudo pip install python-openstackclient

Or pip3 for Python3.

[user@localhost]$ sudo pip3 install python-openstackclient

You may see the following error when installing.

Command python setup.py egg_info failed with error code 1

If so, run the following:

[user@localhost]$ pip install --upgrade setuptools

Or if you're using Python 3:

[user@localhost]$ pip3 install --upgrade setuptools

Try again and you should be able to install without an error.

Configuration

The easiest way to configure the client is to use the OpenRC file. View the following article for instructions on how to download this file:

Basic commands

The OpenStack command line client combines the functionality of all of the other OpenStack service specific command line clients, such as the nova client and the cinder client. Here are some basic commands that are useful: