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.
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:
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 OpenStackCLI
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
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.
While in interactive mode enter
help to get all the different commands.
If you only need to find a specific command enter:
$ openstack help | grep "your command"
$ openstack help | grep list
This will return all list commands.
Step 5 - 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.
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:
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.
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.
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.
More tutorials about using the Command Line Interface can be found here.