Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The WSL way

This is by far the easiest method:

  1. Install Ubuntu on WSL via the links and guides here
  2. Start the Ubuntu "program", and run  sudo apt install python3-openstackclient
  3. Carry on working as you're used to from a native Linux shell

The python way

This is a step-by-step guide to use the Openstack CLI CLI  via native python-install on Windows. The following is tested on Windows 10 only. It will take you through installing all the dependencies.

Install prerequisites

The python-openstackclient needs some Microsoft C++ Build tools in order to be successfully installed

  1. Go to this link, and download Microsoft C++ Build Tools.
  2. Open the program and select Desktop Development with C++, but in the right hand menu, under optional, select only MSVC v142 - VS 2019 C++ x64/x86 build tools (latest) and Windows 10 SDK
    Image Added
  3. Do a little reflection around why MS forces you to install over 6GB of software do be able to compile some python modules...

Install Python for Windows

  1. Go to this link, and grab the latest Python 2 3 Release. Choose the Windows x86-64 MSI Installer, and install the package. Accept all the defaults. Do not change the installation path, install Python to C:\Python27
  2. Right click on the start menu button, and select "System". In this window, click "Advanced system settings"
    Image Removed
  3. In the System Properties window, select the Advanced tap, and click Environment Variables
    Image Removed
  4. Now we need to create a new System variable, and then edit the System Variable "Path"
    1. Click "New" under the System variables box, and enter "PYTHON_HOME" and "C:\Python27" for name and value. Click OK.
      Image Removed
    2. Locate the variable "Path", and click "Edit"
      Image Removed
    3. Click "New" and add both "%PYTHON_HOME%\" and "%PYTHON_HOME%\Scripts\" to the list. Move them to the top of the list, and click "OK" in all the windows you've opened so far.
      Image Removed

...

  1. Check the Add Python 3.xx to PATH option, and select Customize Installation
    Image Added
  2. Select at least pip and the for all users (requires eleveation). The other options are just nice to have.
    Image Added
  3. Select Install for all users and Precompile standard library
    Image Added

Your Python for Windows installation is now ready for use.

Add user-specific python script directory to path

The installer does not add its script directory to the users PATH environment variable. This is recommended to do, to avoid problems later.

  1. Righ-click the windows-button and select System
  2. On the bottom of that page, select Advanced System Settings
    Image Added
  3. Select the advanced tab and click Environment variables
    Image Added
  4. Hilight Path in "User variables for <USERNAME>" and click Edit...
    Image Added
  5. Click New and enter %APPDATA%\Python\Python310\Scripts and click OK on all the windows that has appeared in this process.
    1. NOTE: Make sure thar you use the Python version actually installed here. The example is valid for Python 3.10. If you i.e install 3.9 og 3.14, use "Python39" or "Python314" respecivley in the path.


Install python-openstackclient

...

To actually make the openstack-client somewhat useful, we need to "translate" the openrc.sh file from bash to powershell. Grab the openrc-file from the OpenStack Web UI as explained here. Copy the file to a new file, and name it <projectname>-openrc.ps1 i.e.

...

Code Block
languagepowershell
# To use an OpenStack cloud you need to authenticate against the Identity
# service named keystone, which returns a **Token** and **Service Catalog**.
# The catalog contains the endpoints for all services the user/tenant has
# access to - such as Compute, Image Service, Identity, Object Storage, Block
# Storage, and Networking (code-named nova, glance, keystone, swift,
# cinder, and neutron).

# *NOTE*: Using the 3 *Identity API* does not necessarily mean any other
# OpenStack API is version 3. For example, your cloud provider may implement
# Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is
# only for the Identity API served through keystone.
$env:OS_AUTH_URL = 'httphttps://172api.skyhigh.16iik.0ntnu.102no:5000/v3'

# With the addition of Keystone we have standardized on the term **project**
# as the entity that owns the resources.
$env:OS_PROJECT_ID = 'c7d892e8b97945c4add0ecab10ed62ad'
$env:OS_PROJECT_NAME = 'PRIV_larsep'
$env:OS_USER_DOMAIN_NAME = 'NTNU'

# unset v2.0 items in case set
$env:OS_TENANT_ID = $Null
$env:OS_TENANT_NAME= $Null

# In addition to the owning entity (tenant), OpenStack stores the entity
# performing the action as the **user**.
$env:OS_USERNAME="larsep"

# With Keystone you pass the keystone password.
$OS_PASSWORD_INPUT= Read-Host -Prompt "Please enter your OpenStack Password for project $env:OS_PROJECT_NAME as user $env:OS_USERNAME" -AsSecureString
$env:OS_PASSWORD = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($OS_PASSWORD_INPUT))

# If your configuration has multiple regions, we set that information here.
# OS_REGION_NAME is optional and only valid in certain environments.
$env:OS_REGION_NAME="SkyHiGh"

$env:OS_INTERFACE='public'
$env:OS_IDENTITY_API_VERSION=3

...