How to use the OpenStack CLI tools on Linux
Estimated time to read: 4 minutes
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:
- A Fuga Cloud account
-
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 Interface
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:
For Ubuntu 18.04:
$ sudo apt update
$ sudo apt install -y python3-pip python3-dev
$ sudo pip3 install --upgrade pip
$ sudo pip3 install python-openstackclient
For CentOS 7:
Step 2 - Installing the configuration file
Now, follow the steps below to install the configuration file:
- Log in to the Fuga Cloud Dashboard
- Go to Account → Access → Credentials
- You can choose a user credential or team credential.
- If you haven’t already, you should create one of these credentials. Hold on to the password.
- Click on download OpenRC. This file contains all necessary configurations for the client.
- 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
-
Run the following command to use the configuration file:
-
Enter the password which matches the username of the contents of the OpenRC file.
Step 3 - Using the OpenStack CLI
You have now installed and configured the OpenStack CLI client and you can start using the OpenStack 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 Interface.
List your instances
List your volumes
List the images
Interactive mode
This might not work on Ubuntu 18.04 depending on your configuration.
If you only enter the command openstack, you enter interactive mode. This mode lets you interact faster with the OpenStack CLI.
While in interactive mode enter help to get all the different commands.Pro tip
If you only need to find a specific command enter:
For instance: This will return all list commands.Step 4 - Creating a new server with CLI
Start an interactive session with:
If you get an error whilst using the interactive session, just prepend openstack to all commands without using the interactive session.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:
This command returns the newly generated private key. Make sure to store this somewhere secure.Now test if the key is created:
Next up is to list the images and flavors we can choose from: In this example, I chose to create a c2.small instance, named CLI Test, on the IPv4 public network and running Ubuntu 18.04 using the newly generated key.2server create cli_test --image Ubuntu 18.04 LTS --flavor c2.small --key-name test_cli_key --network public
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. Besides 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.