How to install OpenStackClient on Windows using Windows Subsystem for Linux on CREODIAS OpenStack Hosting

In this tutorial, you will control your OpenStack environment in a deeper and more precise way using the CLI (Command Line Interface). Of course, you can use the Horizon GUI (Graphical User Interface) running in your browser, but the CLI includes additional features like the ability to use scripts for more automated management of your environment.

The instructions for installing Windows Subsystem for Linux are based on the official Windows documentation found at https://learn.microsoft.com/en-us/windows/wsl/.

What We Are Going To Cover

  • Installing Windows Subsystem for Linux on Microsoft Windows

  • Installing the OpenStack CLI client and authenticating

Prerequisites

No. 1 Hosting

You need a CREODIAS hosting account with Horizon interface https://horizon.cloudferro.com.

No. 2 Computer running Microsoft Windows

Your computer must be running Microsoft Windows. This article is written for Windows Server 2019 version 1709 or later. The instructions for the following versions are linked in the appropriate location of this article:

  • Windows 10 version 1903 up to and excluding version 2004

  • Windows 10 version 2004 or later (Build 19041), Windows 11

  • Windows Server 2022

No. 3 Optional – software for 2FA authentication

Your account at CREODIAS cloud may have two-factor authentication enabled. It means that apart from the usual username and password combination, you also need software to generate the TOTP – the six-digit code for the additional, second step of authentication. This article will provide additional technical details: How to activate OpenStack CLI access to CREODIAS cloud using one- or two-factor authentication.

Step 1: Check the version of Windows

Right-click on your start menu and left-click “System”.

A screen will appear in which you will see the version of your Microsoft Windows operating system. Memorize it or write it somewhere down.

Step 2: Install Ubuntu on Windows Subsystem for Linux

Note

The following instructions from this step are for Windows Server 2019 version 1709 or later. If you are running a different operating system, please follow the instructions found under the appropriate link and skip to Step 3:

Enter the following website: https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions. Download Ubuntu 20.04 using the provided link. This tutorial assumes that your browser saved it in your Downloads directory - if that is not the case, please modify the instructions accordingly.

Locate the downloaded file:

../_images/wsl01_creodias.png

Right-click it and select the option Rename.

../_images/wsl02_creodias.png

Rename the downloaded file to Ubuntu.zip:

../_images/wsl03_creodias.png

Right-click the file and select Extract All….

../_images/wsl04_creodias.png

In the wizard that appeared do not change any options and click Extract:

../_images/wsl05_creodias.png

A directory called Ubuntu should have appeared:

../_images/wsl06_creodias.png

Enter that folder and view its content:

../_images/wsl07_creodias.png

Memorize or write somewhere down the name of the .appx file which ends with x64.

Open your Start menu. Right-click the entry Windows PowerShell and select Run as administrator:

../_images/wsl08_creodias.png

In the displayed window type the following command and press Enter:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

The following progress bar should have appeared:

../_images/wsl09_creodias.png

After the end of the process you will be asked if you want to restart your computer to complete the operation:

../_images/wsl10_creodias.png

Make sure that the restart will not cause any disruptions and press Y to restart.

During the reboot you will see the following process message:

../_images/wsl11_creodias.png

Once the reboot is completed, start the PowerShell again as described previously.

Run the following command (replace Ubuntu.appx with the name of your .appx file which you memorized or wrote somewhere down previously):

Add-AppxPackage .\Downloads\Ubuntu\Ubuntu.appx

During the process, you will see the status bar similar to this:

../_images/wsl12_creodias.png

Once the process is finished, execute the following command (replace the C:\Users\Administrator\Ubuntu path with the location of your Ubuntu folder):

$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User")

Your newly installed Ubuntu should appear in your Start menu:

../_images/wsl13_creodias.png

Run it. You will see the following message:

../_images/wsl14_creodias.png

Wait until this process finishes. After that, you will get a prompt asking you for your desired username (which is to be used in the installed Ubuntu):

../_images/wsl15_creodias.png

Type it and press Enter. You will now be asked to provide the password for that account:

../_images/wsl16_creodias.png

Note

Your password will not be visible as you type, not even as masking characters.

Input your password and press Enter. You will then be asked to type it again:

../_images/wsl17_creodias.png

If you typed the same password twice, it will be set as the password for that account. You wil get the following message as confirmation:

../_images/wsl18_creodias.png

Wait for a short time. Eventually your Linux environment will be ready:

../_images/wsl19_creodias.png

Step 3: Install OpenStack CLI in an isolated Python environment

Now that you have installed Windows Subsystem on Linux running Ubuntu on your Windows computer, it is time to install OpenStack CLI.

Update the software running on your Ubuntu:

sudo apt update && sudo apt upgrade

Once the process is finished, install the python3-venv package to create a separate Python environment:

sudo apt install python3-venv

Create a virtual environment in which you will have OpenStack CLI installed:

python3 -m venv openstack_cli

Enter your new virtual environment:

source openstack_cli/bin/activate

Upgrade pip to the latest version:

pip install --upgrade pip

Install the python-openstackclient package:

pip install python-openstackclient

Verify that the OpenStack CLI works by viewing its help:

openstack --help

If the command shows its output using a pager, you should be able to use the arrows (or vim keys - J and K) to scroll and Q to exit.

If everything seems to work, time to move to the next step - authentication to your user account on CREODIAS.

Step 4: Download your OpenStack RC File

Login to CREODIAS hosting account with Horizon interface https://horizon.cloudferro.com.

Click on your username in the upper right corner. You will see the following menu:

../_images/wsl20_creodias.png

If your account has two factor authentication enabled, click the option OpenStack RC File (2FA). If, however, it does not have it enabled, use the OpenStack RC File option.

The RC file will be downloaded. Memorize or write somewhere down the name of that file. Move this file to the root location of your C: drive.

Step 5: Move the RC file to your Ubuntu environment

Return to your Ubuntu window.

You will now copy your RC file to your Ubuntu environment. Since Windows Subsystem for Linux mounts the C: drive under /mnt/c, the command for copying your RC file to your Ubuntu environment is as follows (replace main-openrc.sh with the name of your RC file):

cp /mnt/c/main-openrc.sh $HOME

Now use the source command on this file to begin the authentication process (replace main-rc.sh with the name of your RC file):

source main-openrc.sh

You will see the prompt for your password. Type your password there and press Enter (the password is still being accepted even if you do not see the characters being typed).

If your account has two factor authentication enabled, you will also see the prompt for your six-digit code. Open software which you use for generating such codes (for example KeePassXC or FreeOTP) and find your code there, as usual. Make sure that you enter it before it expires. If you think that you will not manage to enter your current code, wait until a new one is generated.

After having entered your code, press Enter.

Now you can test whether you have successfully authenticated by listing your VMs:

openstack server list

How to run this environment later?

If you close the window with Ubuntu and reopen it, you will see that you are no longer in the openstack_cli environment you created and thus no longer have access to OpenStack. You will need to reenter the openstack_cli environment and reauthenticate.

After reopening the Ubuntu Window, execute the source command on the file used for entering you openstack_cli environment, just like previously:

source openstack_cli/bin/activate

Now, reauthenticate by invoking the source comand on your RC file (replace main-openrc.sh with the name of your RC file):

source main-openrc.sh

Type your password and press Enter. You should now be able execute the OpenStack CLI commands as usual.

What To Do Next

After installing the OpenStack CLI client and activating your new RC file, you can use other articles to perform operations on CREODIAS cloud:

How to create a set of VMs using OpenStack Heat Orchestration on CREODIAS

Generating and authorizing Terraform using Keycloak user on CREODIAS

How to upload your custom image using OpenStack CLI on CREODIAS

How to create a VM using the OpenStack CLI client on CREODIAS cloud

How To Use Command Line Interface for Kubernetes Clusters On CREODIAS OpenStack Magnum