Skip to content

Introduction

The OpenRC file will set your environment variables so that you can quickly connect your Openstack client to your Breqwatr environment. You can download your users specific file after logging into the Arcus User Interface.

How to install OpenStack CLI on Windows

There are two options available to use OpenStack client depending on the preference of the system engineers.

Note It is recommended to install and configure OpenStack client either on a MacOS or a Linux Operating System. If a Windows Operating System is used, then follow option 1 which simply uses BASH within the Windows Subsystem for Linux or if you prefer PowerShell follow option 2.

OpenStack CLI Options:

  • Option 1: Windows Subsystem for Linux and BASH

    • Step 1: Install the Windows Subsystem for Linux
    • Step 2: Install Python3
    • Step 3: Create and source the virtualenv
    • Step 4: Install OpenStack Client
    • Step 5: Test OpenStack connectivity
  • Option 2: Windows SDK C++ Build Tools and PowerShell

    • Step 1: Install Python3
    • Step 2: Install Microsoft C++ Build Tools
    • Step 3: Create a Python3 Virtual Environment
    • Step 4: Set Execution Policy
    • Step 5: Activate the Virtual Environment
    • Step 6: Install the Client Tools
    • Step 7: Save Source-OpenRC.ps1 script
    • Step 8: Test OpenStack Connectivity

Option 1: Windows Subsystem for Linux and BASH

Step 1: Install the Windows Subsystem for Linux

The Windows Subsystem for Linux lets system engineers run a Linux environment --including most command-line tools, utilities and applications -- directly on Windows without dualboot setup. You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.

You can install Windows Subsystem for Linux (WSL) by entering this command in an administrator PowerShell or Windows Command Prompt and then restarting your machine.

wsl --install -d Ubuntu-20.04

If you are running older build of Windows, that may not be supported. The manual installation steps for older versions of WSL. Manual installation Steps

Step 2: Install Python3

apt-get update
apt-get install -y python3 python3-pip virtualenv

Step 3: Create and source the virtualenv

virtualenv --python=python3 env/
source env/bin/activate

Step 4: Install OpenStack Client

apt-install python3-openstackclient

Step 5: Test OpenStack connectivity

After installing the OpenStack Client, you can now need to authenticate to OpenStack by following the steps:

Option 2: Windows SDK C++ Build Tools and PowerShell

Step 1: Install Python3

Windows 10 or Windows 11

Open PowerShell as administrator. Type python3. if it is not installed, the Microsoft Store will open. Click Install.

If python is already installed, the interpreter will open instead. Enter "exit()" in this case to quit out of the interpreter.

python3

Windows Server 2019

  1. Download the latest Python3 release for Windows. Python Website

Download Python

  1. Then, open your downloaded file and check the box ‘Add Python 3.10.4 to PATH’. This option will add python Path to the system environment variable.

Python Executable

When your installation is completed click on close to exit from the window.

Step 2: Install Microsoft C++ Build Tools

  1. Download Microsoft Visual Studio Community 2022. Microsoft Visual Studio Website

Microsoft Visual Studio Community

  1. Then, open your downloaded file and Continue with the installation.

Visual Studio Executable

  1. Select Desktop development with C++ option in the installer. Click Install.

Desktop Development with C++

  1. After finishing the installation. Restart the computer.

Visual Studio Installer

Step 3: Create a Python3 Virtual Environment

A virtual environment is highly recommended to keep your pip3 install isolated from any other python environments that maybe present. Open PowerShell as administrator.

python -m venv $env:USERPROFILE\Documents\python-venvs\env

Step 4: Set Execution Policy

This is required as a PowerShell script will need to be run

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Step 5: Activate the Virtual Environment

This environment will need to be activated every session before use. If PowerShell or Windows Terminal is closed or the current session exits, it will need to be activated again.

 Set-Location $env:USERPROFILE\Documents\python-venvs\env\Scripts\
.\Activate.ps1

Step 6: Install the Client Tools

(env) pip3 install wheel
(env) python -m pip install --upgrade pip
(env) pip3 install python-openstackclient

Step 7: Save Source-OpenRC.ps1 script

Save the Source-OpenRC.ps1 script below in the path $env:USERPROFILE\Documents\python-venvs\env\Scripts\Source-OpenRC.ps1

<#
.Synopsis
   Source an OpenStack OpenRC file.
.DESCRIPTION
   This script allows you to source an OpenRC file that can be downloaded from breqwatr portal.
   After running the script you'll be able to use the OpenStack
   command-line tools. These need to be installed separately.
.PARAMETER LiteralPath
   The OpenRC file you downloaded from the OpenStack dashboard.
.EXAMPLE
   Source-OpenRC H:\project-openrc.sh
.LINK
   http://breqwatr.company.com
#>

If ($args.count -lt 1) {
    Write "Please provide an OpenRC file as argument."
    Exit
}

ElseIf ($args.count -gt 1) {
    Write "Please provide a single OpenRC file as argument."
    Exit
}

ElseIf (-Not (Test-Path $args[0])) {
    Write "The OpenRC file you specified doesn't exist!"
    Exit
}
Else {
    $openrc = $args[0]
    $error = "The file you specified doesn't seem to be a valid OpenRC file"

    # With the addition of Keystone, to use an openstack cloud you should
    # authenticate against keystone, which returns a **Token** and **Service
    # Catalog**.  The catalog contains the endpoint for all services the
    # user/tenant has access to - including nova, glance, keystone, swift.
    #

    $os_project_domain_name = Select-String -Path $openrc -Pattern 'OS_PROJECT_DOMAIN_NAME'
    If ($os_project_domain_name) {
        $env:OS_PROJECT_DOMAIN_NAME = ([string]($os_project_domain_name)).Split("=")[1].Replace("`"","")
    }
    Else {
        Write $error
        Exit
    }

    $os_project_name = Select-String -Path $openrc -Pattern 'OS_PROJECT_NAME'
    If ($os_project_name) {
        $env:OS_PROJECT_NAME = ([string]($os_project_name)).Split("=")[1].Replace("`"","")
    }
    Else {
        Write $error
        Exit
    }


    $os_username = Select-String -Path $openrc -Pattern 'OS_USERNAME'
    If ($os_username) {
        $env:OS_USERNAME = ([string]($os_username)).Split("=")[1].Replace("`"","")
    }
    Else {
        Write $error
        Exit
    }

    $os_auth_url = Select-String -Path $openrc -Pattern 'OS_AUTH_URL'
    If ($os_auth_url) {
        $env:OS_AUTH_URL = ([string]($os_auth_url)).Split("=")[1].Replace("`"","")
    }
    Else {
        Write $error
        Exit
    }


    $os_identity_api_version = Select-String -Path $openrc -Pattern 'OS_IDENTITY_API_VERSION'
    If ($os_identity_api_version) {
        $env:OS_IDENTITY_API_VERSION = ([string]($os_identity_api_version)).Split("=")[1].Replace("`"","")
    }
    Else {
        Write $error
        Exit
    }

    $os_image_api_version = Select-String -Path $openrc -Pattern 'OS_IMAGE_API_VERSION'
    If ($os_image_api_version) {
        $env:OS_IMAGE_API_VERSION = ([string]($os_image_api_version)).Split("=")[1].Replace("`"","")
    }
    Else {
        Write $error
        Exit
    }


    # With Keystone you pass the keystone password.
    $password = Read-Host 'Please enter your OpenStack Password' -AsSecureString
    $env:OS_PASSWORD = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))

}

Step 7: Test OpenStack Connectivity

  1. After installing the OpenStack Client, authenticate to OpenStack. Download the openrc file: How to download the openrc file

  2. Save the project-openrc.sh file as the one shown below in the path $env:USERPROFILE\Documents\python-venvs\env\Scripts\-openrc.sh

export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=john
export OS_USERNAME=john
export OS_PASSWORD=
export OS_AUTH_URL=https://cloud.breqwatr.com:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
  1. Source the project-openrc.sh file as follows
 Set-Location $env:USERPROFILE\Documents\python-venvs\env\Scripts\
.\Activate.ps1
.\Source-OpenRC.ps1 .\<project>-openrc.sh
  1. Type the password

Source Openstack Project

  1. Verify OpenStack commands, for example lookup for desired values:

Openstack Server List

Openstack Flavor List

How to install OpenStack CLI on Linux

Installation and configuration of a Linux Host to issue commands to your Openstack installation.

  • Step 1: Install the Openstack client
  • Step 2: Get the OpenRC access file
  • Step 3: Issuing Openstack commands

Step 1: Install the Openstack Client

-- # Install python3
apt-get update
apt-get install -y python3 python3-pip virtualenv

-- # Create and source the virtualenv
virtualenv --python=python3 env/
source env/bin/activate

-- # Use pip to install the openstack client
pip install python-openstackclient

Step 2: Get the OpenRC Access File

Download the OpenRC file from the Arcus Client: How to download the openrc file

Reminder! If you are using a self-signed certificate you will need to include the .path to a copy of the certificate file in your OpenRC file.

Step 3: Issuing Openstack commands

After sourcing into your virtualenv and sourcing your OpenRC file you should be able to run openstack commands like:

(env) root@demo-server:~#openstack compute service list
(env) root@demo-server:~#openstack server list

You can also enter console mode which will allow you to enter multiple commands at once:

(env) root@demo-server:~#openstack
>compute service list

How to install OpenStack CLI on MacOS

Installation and configuration of a Mac Host to issue commands to your Openstack installation.

  • Step 1: Install the Openstack client
  • Step 2: Get the OpenRC access file
  • Step 3: Issuing Openstack commands

Step 1: Install the Openstack Client

Download and install python3 package for MacOS: Python Downloads Website

--- # Install, create and source the virtualenv
python3 -m pip install virtualenv
python3 -m virtualenv env/
source env/bin/activate

--- # Use pip to install the openstack client
python3 -m pip install python-openstackclient

Step 2: Get the OpenRC Access File

Download the OpenRC file from the Arcus Client: How to download the openrc file

Reminder! If you are using a self-signed certificate you will need to include the .path to a copy of the certificate file in your OpenRC file.

Step 3: Issuing Openstack commands

After sourcing into your virtualenv and sourcing your OpenRC file you should be able to run openstack commands like:

(env) demo@MacBook-Pro ~ %openstack compute service list
(env) demo@MacBook-Pro ~ %openstack server list

You can also enter console mode which will allow you to enter multiple commands at once:

(env) demo@MacBook-Pro ~ %openstack
>compute service list

How to use OpenStack CLI

After installing the OpenStack CLI tools on the Operating System of your choice, you can start interacting with OpenStack infrastructure. For more information, refer to link OpenStack Command List

Openstack help

You can explore the Openstack help for the available commands.

(env) demo@MacBook-Pro ~ %openstack --help

The following commands show an example of how create an instance using CLI.

List Flavors

List the flavors to show the ID, name, the amount of memory, the number of vCPUs for each flavor.

(env) demo@MacBook-Pro ~ %openstack flavor list

List Networks

List the networks to show the ID, name, subnet.

(env) demo@MacBook-Pro ~ %openstack network list

List Images

List the images to show the ID, name, status.

(env) demo@MacBook-Pro ~ %openstack image list

Create a Volume from Image

Create a volume from an image by specifying the image, size and volume name.

(env) demo@MacBook-Pro ~ %openstack volume create --image "Ubuntu 20.04" --size 1 webtest-vol

List Volumes

List the volumes to show the ID, name, type, status. Verify that the new volume was created.

(env) demo@MacBook-Pro ~ %openstack volume list

Create a new Instance

Create the instance by specifying the volume, the flavor, network and instance name.

(env) demo@MacBook-Pro ~ %openstack server create --volume webtest-vol --flavor tiny-0 --network public webtest

List Instances

List the instances to show the ID, name, status. Verify that the new instance was created.

(env) demo@MacBook-Pro ~ %openstack server list