Skip to content

How to use the OpenStack CLI tools on Windows

Estimated time to read: 4 minutes

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:

  1. How to use the OpenStack CLI tools on Mac OS X
  2. How to use the OpenStack CLI tools on Linux

We recommend using WinPython, this is a portable Python application which you can register to Windows.

Step 1 - Installing WinPython

Use the latest stable WinPython installer to download and install WinPython.

Open the WinPython Powershell or the WinPython Command Prompt (located in the folder where you just installed WinPython) and verify that the installation has succeeded by using these commands:

python --version
pip --version

Step 2 - Setting environment variables in session

To communicate with your OpenStack API, you’ll need to configure some variables. The default OpenStack RC file is only built for UNIX-based systems, so it will not work on Windows.

This means that we have to set our environment variables manually, keep in mind that we are only setting these settings for the current Powershell/Command Prompt session, and they will be deleted (automatically) after closing the window.

set OS_AUTH_URL=https://identity.api.ams.fuga.cloud:443/v3
set OS_USERNAME=*USERNAME*
set OS_PASSWORD=*PASSWORD*
set OS_PROJECT_ID=*PROJECT ID*
set OS_DOMAIN_ID=*DOMAIN_ID*

If you’re unsure what to fill in, you can download the OpenStack RC file from the dashboard (through Account → Access). Open the RC file in Notepad and you will find these variables (except password) and their values.

Step 3 - Install OpenStack CLI

Now in the Powershell or Command Prompt:

pip install -U buildtools
pip install python-openstackclient

Check if everything works:

openstack server list

If your list of VM’s are being returned, everything is set up.

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

$ 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 OpenStack CLI.

This might not work on Ubuntu 18.04 depending on your configuration.

$ 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

If you get an error whilst using the interactive session, just prepend openstack to all commands.

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. Make sure to store this securely.

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 c2.small instance, named CLI Test, on the IPv4 public network and running Ubuntu 18.04 using the newly generated key.

server create cli_test --image Ubuntu 18.04 LTS --flavor c2.small --key-name test_cli_key --network public

After a few seconds, the server is created and built.

Alternatives

Alternatively, you could use the latest stable Python installer to download and install regular Python and then set the OpenStack configuration as environmental variables. This is possible, but we cannot guarantee that does in fact work.

Conclusion

In this tutorial, you’ve learned how to use the OpenStack Command Line Interface tools on Windows using WinPython. 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.