In this tutorial, we’re going to look into installing all the CLI toolsets required to interact with an OpenStack cloud (taking our cloud as an example). At the time of writing this article, there are currently two OpenStack CLI toolsets.

Introduction

The first one consists of multiple different tools, each designed to manage a specific component of OpenStack. It offers a nova command to manage compute, neutron to manage networking, glance to manage images and much more.

However, the first toolset is currently on it’s way out and it is being replaced by a common OpenStack client which aims to cover all different services from a single openstack tool, which should simplify and usage and interaction with any OpenStack Cloud.

Prerequisites

This tutorial assumes that you already have Python installed on your operating system. If you’re running a distribution of Linux or Mac OS X then it is likely already preinstalled on your operating system. If you’re using Windows, you’ll have to install Python.

In addition, you’ll have to make sure you have pip, the recommended tool for installing Python packages installed. If you don’t have it, you can install it with the instructions below. Windows installations now have it included by default so you won’t have to install it.

 

 

$ sudo apt-get -y install python-pip

$ sudo yum -y install python-pip

$ sudo easy_install -U pip

Installation

The process of installing the OpenStack clients is quite easy, both for the former and new toolsets. We’ll do it all at one command but the thing to note is that python-openstackclient is the new client while the others are simply part of the older toolset.

It’s important to note that we’re using sudo to install in this case. The reason behind this is that we want the installation of the packages to be global, so that you can call the CLI anywhere on your machine by simply typing openstack or nova, etc.

$ sudo pip install -U python-keystoneclient python-novaclient python-heatclient python-swiftclient python-neutronclient python-cinderclient python-glanceclient python-openstackclient

Once this is all done, you should be able to type nova, glance, neutron or openstack in your CLI, but you will likely be informed that you must provide credentials when trying to perform any actions.

Configuration

This part is quite cloud-specific so we’ll try to cover as much as we can to help you get your credentials. There’s usually 4 or 5 items that you need in order to be able to successfully authenticate to an OpenStack cloud.

ParameterEnvironment VariableDescription
Authentication URLOS_AUTH_URLThis typically is the URL of where the Keystone service runs
Region (optional)OS_REGION_NAMEIf you’re using a cloud with multiple regions, this would need to be specified.
UsernameOS_USERNAMEThe username you’re provided for the OpenStack API.
PasswordOS_PASSWORDThe password you’re provided for the OpenStack API.
Tenant NameOS_TENANT_NAMEThis is the tenant you’re trying to access, usually it will be provided to you.

You’ll have to get all that information first before continuing with this. We have instructions on how to get this information from our OpenStack Public Cloud and users who are currently accessing OpenStack via the Horizon dashboard.

 

 

It’s quite simple to get your credentials on the VEXXHOST Public Cloud. All you’ll have to do is start by logging into your customer center with your account details.

Once you’ve logged in, click on the “API Credentials” button on the sidebar which should send you to a page that contains all your information and environment variables.

You’ll need to login to your OpenStack dashboard with your credentials first of all. Once you’re logged in, make sure that the you have the correct “Project” and “Region” selected from the top of the page.

Afterwards, click on the “Project” tab, open the “Compute” section if it is not open and click on “Access & Security”. Once there, click on “API access”.

On that page, click on “View Credentials” and you’ll have all your information listed there. For the password, it will be the one you used to login to your OpenStack dashboard, as Horizon does not list it.

Once you have all the information you need handy, we’ll configure your environment to include all the these required variables so that you can use the OpenStack CLI with no problems. Depending on what type of operating system you’re running, you’ll have to make some different changes.

If you’re using a different shell than the default built-in one with your operating system, you’ll have to follow the instructions specific to your shell, if you haven’t changed it, you can use the instructions below.

 

 

This tutorial assumes that you’re using the default shell, `bash`. If you’re not, you’ll have to follow instructions specific to your shell.

You’ll need to edit the file located in your home directory called `.bash_profile`. You can use your favorite text editing tool to make the changes. All you’ll need to do is add the following lines at the end of the file

OS_AUTH_URL=... OS_REGION_NAME=... OS_USERNAME=... OS_PASSWORD=... OS_TENANT_NAME=...

You’ll have to update the dotted part by the value which you’ve retrieved earlier in this tutorial. If you’re using the VEXXHOST public cloud, this information is already provided to you on the API credentials page.

The process for adding environment variables under Windows a bit more challenging, but it’s a bit easier overall. Start by going to the “Control Panel” from the Start Menu and go to the “System and Security” section, select System from there.

Once there, click on the “Advanced” tab and click on the environment variables button on the bottom of the window displayed. Once you’re there, click on the “New” button under the “User variables” section of the Environment Variables window.

In there, for the variable, use the ones listed in table above (such as `OS_AUTH_URL`) and for the value, use the ones you determined for the cloud you’re currently attempting to connect to.

Once you’ve completed this process, your OpenStack environment variables should be fully configured. It’s extremely important that you restart your open shells in order for the environment variables to be applied.

Conclusion

Once you’ve done this, you can test out that you can successfully authenticate. You can now start using all of the OpenStack toolset directly from your CLI which makes it even easier to manage your infrastructure.

$ nova credentials
+------------------+----------------------------------+
| User Credentials | Value                            |
+------------------+----------------------------------+
| id               | 1fe021efed5f4fb68c095d6f85f18f4b |
| name             | user                             |
| roles            | []                               |
| roles_links      |                                  |
| username         | user                             |
+------------------+----------------------------------+
+-----------+-----------------------------------------------------+
| Token     | Value                                               |
+-----------+-----------------------------------------------------+
| audit_ids | ["2_xwfWJFTJyLxyFGDj_9oQ"]                          |
| expires   | 2015-06-19T18:51:35Z                                |
| id        | df5c6b9ffdf44f2bffabfcff69c4f46b                    |
| issued_at | 2015-06-19T17:51:35.179874                          |
| tenant    | {"enabled": true, "description": "tenant", "name":  |
|           | "tenant", "id": "d75ffb0f98b5ffcc9e4e0fff2e1ff2e4"} |
+-----------+-----------------------------------------------------+

You can also start using and learning the new openstack CLI tool, you can use the openstack help command to get information about what you can do from it, but it’s extremely easy to use, this is how simple you can get a server up.

$ openstack server create --image "Ubuntu 14.04.2 LTS" --flavor nb.1G ubuntu-server

Hopefully by now you have all the tools you need to run your infrastructure directly from your terminal, which is an extremely powerful tool to help for automation and allowing you to easily create and anything from servers to networks.