How to use the OpenStack CLI tools on Mac OS X
Estimated time to read: 4 minutes
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:
- A Fuga Cloud account
- A device running Mac OS X
In case you’re running Windows or Linux, please check out the following guides:
Step 1 - Installing Python 3
If you want to use the Dockerfile (explained in step 3), you can omit this step.
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.
To install homebrew use the following command lines:
Using brew to install Python3"Install a stable Python binary from Python.org downloads
Installing the OpenStack command line tools
Now Python3 is installed you can install the OpenStack command line tools:
Step 2 - Install the configuration file
Now, follow the steps below to install the configuration files:
- Log in to the Fuga Cloud Dashboard
- Then go to the Access tab
- Here you can create OpenStack API Credentials (Remember to save the password in a safe place)
- Now you can choose to download one of three files (Dockerfile, OpenRC, Clouds.yaml). These files contain all necessary configurations for the clients.
save this file to the folder where your project resides
Build the Docker container
Where <$PASSWORD> is used fill in the password of your OpenStack API Credentials and instead of <$PROJECT_DIR> you fill the directory where your project resides on your disk.Run the interactive CLI
--rm openstackcli removes the container when you close it. This way your system doesn’t get cluttered with unused containers. You can check this with: If you want to exit the environment, use:Save this file to the folder where your project resides. <$CLOUD_NAME> is the name of the cloud specified on line 2 in the clouds.yaml file. By default this is fuga.
List your instances
List your volumes List the imagesStep 3 - Using the Fuga CLI
You have now installed and configured the OpenStack CLI client and 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.
Interactive mode
If you only enter the command OpenStack, you enter interactive mode. This mode lets you interact faster with the Fuga CLI.
While in interactive mode, you don’t have to use the OpenStack command on every single command line. For example:
In interactive mode just bij using the $ openstack command. While in interactive mode enter help to get all the different commands. If you only need to find a specific command enter: For instance: This will return all list commands.If you want to exit the environment, use
Step 4 - Creating a new server with CLI
First, you need to create a new key. You can name it, for example, test_cli_key or use an existing key.
Creating a key with the CLI can be done the following command:
This command returns the newly generated private key. Store this somewhere safe.Now test if the key is created:
Next up is to list the images and flavors you can choose from: The example below shows you a c2.small instance, named CLI-Test and running Ubuntu 18.04 LTS using the newly generated key.$ openstack server create --image b88f311a-b5f6-49d0-ad44-5304f9a8ef9b --flavor c2.small --key-name test_cli_key CLI-test
Step 5 - Exiting the environment
Deactivating the virtualenv
When you’re done with the virtualenv, run deactivate. You’ll see your prompt revert to normal.
Reactivating the virtualenv
Anytime you want to run your virtual environment, activate the “fugaio” virtualenv as shown in step 3. This will put you into the appropriate virtualenv with all the necessary modules and dependencies. When you’re done, simply deactivate it again.
Using the clouds.yaml file
Unless you’re in a virtualenv, you don’t have to do anything.
Using the Dockerfile
Press Ctrl-D or type exit in the active terminal to exit Interactive mode.
Conclusion
In this tutorial, you’ve learned how to use the OpenStack Command Line Interface tool on Mac OS X. You leared how to list your instance and volumes using this tool. 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.