How to use the OpenStack CLI tools on Linux
Tutorials Intermediate

How to use the OpenStack CLI tools on Linux

This tutorial describes how to use the OpenStack Command Line Interface (CLI) tools on Linux. For example, you will learn how to list your instances and volumes by using the CLI. You will also learn how you can launch a new instance by using the CLI.

Prerequisites

For this tutorial you’ll need the following:

  1. A Fuga Cloud account
  2. A device running one of the following Linux distributions:
    • Debian
    • Ubuntu
    • CentOS
    • Fedora

In case you’re running Windows or Mac OS X, please check out the following guides:

Step 1 - Installing the OpenStack Command Line Tools

The first step is to install the OpenStack CLI tools. Depending on the Linux distribution you use, use one of the commands below.

For Debian 9:

$ sudo apt update
$ sudo apt install -y python3-pip python3-dev
$ sudo pip3 install --upgrade pip
$ sudo pip3 install python-openstackclient

For Debian 8:

$ sudo apt update
$ sudo apt install -y python3-pip python3-dev
$ sudo pip3 install --upgrade pip
$ sudo pip3 install setuptools --upgrade
$ sudo pip3 install python-openstackclient

For Ubuntu 16.04:

$ sudo apt update
$ sudo apt install -y python3-pip python3-dev
$ sudo pip3 install --upgrade pip
$ sudo pip3 install python-openstackclient

For Ubuntu 14.04:

$ sudo apt update
$ sudo apt install -y python-pip python-dev
$ sudo pip install --upgrade pip
$ sudo pip install python-openstackclient

pyOpenSSL and Cryptography don’t like python2, so all the given instruction can also be done with python3 and pip3, or just use the instructions from Ubuntu 16.04

For CentOS 7:

$ sudo yum update
$ sudo easy_install pip
$ sudo pip install --upgrade pip
$ sudo yum install python-devel gcc
$ sudo pip install python-openstackclient

For Fedora 23:

$ sudo dnf update
$ sudo pip3 install --upgrade pip
$ sudo pip3 install -U setuptools
$ sudo dnf install gcc python3-devel redhat-rpm-config
$ sudo pip3 install python-openstackclient

Step 2 - Installing the configuration file

Now, follow the steps below to install the configuration file:

  1. Log in to the Fuga Cloud Dashboard
  2. Go to Compute → Access & Security → API Access
  3. Click on download OpenStack RC file. This file contains all necessary configurations for the clients. You should open and edit this file with a text editor.
  4. Now copy the contents of this file and paste this in a new text file on the machine where you have installed the OpenStack CLI clients, for example: ~/.fuga-openrc.sh
  5. Run the following command to use the configuration file:

    source ~/.fuga-openrc.sh
    
  6. Enter your Fuga password

Step 3 - Using the Fuga CLI

You have now installed and configured the OpenStack CLI client and you can start using the Fuga CLI. The following are some examples you can try. You can also call openstack help for all available commands. For more in-depth information, check out OpenStack command-line clients.

List your instances

$ openstack server list

List your volumes

$ openstack volume list

List the images

$ openstack image list

Interactive mode

If you only enter the command openstack, you enter interactive mode. This mode lets you interact faster with the Fuga CLI.

$ openstack

While in interactive mode enter help to get all the different commands.

Pro tip

If you only need to find a specific command enter:

$ openstack help | grep "<your command>"

For instance:

$ openstack help | grep list

This will return all list commands.

Step 4 - Creating a new server with CLI

Start an interactive session with:

$ openstack

First, create a new key named, for example, test_cli_key or use an existing key.

Creating a key with the CLI can be done with the following command:

keypair create test_cli_key

This command returns the newly generated private key. Store this somewhere save.

Now test if the key is created:

keypair list

Next up is to list the images and flavors we can choose from:

image list
flavor list

In this example I chose to create a c1.small instance, named CLI Test and running Debian 9 using the newly generated key.

server create cli_test --image 5a2a94e7-3364-4bf8-a66b-ac84bc2c92de --flavor c1.small --key-name test_cli_key

After a few seconds the server is created and built.

Conclusion

In this tutorial, you’ve learned how to use the OpenStack Command Line Interface tools on a Linux distribution, like Debian or Ubuntu. By using these tools you learned how to list your instances and volumes. Beside this, you also learned how to launch a new instance by using the CLI.

More tutorials about using the Command Line Interface can be found here.

Was this article helpful?


Next article:

How to use the OpenStack CLI tools on Windows

This tutorial describes how to use the OpenStack Command Line Interface (CLI) tools on Windows. For example, you will learn how to list your instances and volumes by using the CLI. You will also learn how you can launch a new instance by using the CLI. Prerequisites For this tutorial you’ll need the following: A Fuga Cloud account A device running Windows In case you’re running Mac OS X or Linux, please check out the following guides: