How to use the OpenStack CLI tools on Mac OS X
Tutorials Intermediate CLI Mac OSX

How to use the OpenStack CLI tools on Mac OS X

This tutorial describes how to use the OpenStack Command Line Interface (CLI) tools on Mac OS X. 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 OS X

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

Step 1 - Installing Python 3

The Openstack command line tools need Python and Python on OS X is utterly broken, but fortunately you can install your own, up-to-date version, using brew. If you haven’t installed this on your system yet:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Using brew we’re going to install Python 3:

brew install python

Step 2 - Installing the OpenStack Command Line Tools

Now Python 3 is installed we can finally install the OpenStack command line tools:

sudo pip3 install python-openstackclient

Step 3 - 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.
  4. Save this file to the folder on the machine where you have installed the OpenStack CLI clients, for example: fugaio/.fuga-openrc.sh
  5. Run the following command to use the configuration file:

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

Step 4 - 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 5 - 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.

Step 6 - Deactivating the virtualenv

When you’re done with the virtualenv, run deactivate. You’ll see your prompt revert to normal.

Reactivating the virtualenv

Now, anytime you want to run your virtual environment, activate the “fugaio” virtualenv as shown above. This will put you into the appropriate virtualenv with all the necessary modules and dependencies. When you’re done, simply deactivate it.

Conclusion

In this tutorial, you’ve learned how to use the OpenStack Command Line Interface tools on Mac OS X. 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 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: 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: