Using the OpenStack Command Line Interface
This tutorial is based around using a Ubuntu 20.04 machine to run the commands shown below. This works both on ‘standard’ installations such as VMs or physical machines, as well as WSL.
At the end of the tutorial, you will have a machine that can control your cloud project using the OpenStack CLI.
Installation
First you need to install the packages that provide the Openstack CLI packages
Update all packages on your machine, then install python
, pip
, and python3-openstackclient
sudo apt update
sudo apt upgrade
sudo apt install python-dev python3-pip python3-openstackclient
Authentication
Once you’ve installed the packages above you have to provide your credentials to use Openstack CLI. This tutorial covers the use of openrc
files, not clouds.yaml
files.
Note that if you are a member of multiple Openstack projects you’ll need to download an openrc file for each project and change which file you are using depending on which project you want to interact with using the CLI. Using a clouds.yaml file with multiple entries may be easier for you in this case.
Navigate to openstack.stfc.ac.uk in your web browser and log in with your credentials.
If you are a member of multiple projects, navigate to the one you want to interact with on the CLI using the dropdown in the top centre of the screen.
On the left of the screen navigate to the ‘Project’ section, then select ‘API Access’
On the right hand side you should see a dropdown that says ‘Download Openstack RC File’. Select this, then select ‘Openstack RC File’. A download should start at this point.
Transfer the file, or the contents of the file to your home directory on the machine or environment you prepared in the Installation step above.
Run the following command to provide your credentials for use with the CLI, replacing the file used in the command with the path to your openrc file. The command should ask for your password, enter it as you did when logging into openstack.stfc.ac.uk
source j-ward-scratch-space-openrc.sh
Note that you will need to re run the above command any time you log out of your machine. Your credentials only apply to your session.
Your credentials are stored in plain text environment variables, do not leave your machine unlocked when your credentials are in use. Do not share credentials between users unless you’re using a service account.
Run the following command to confirm that you can now use the CLI. You should see a similar output to the ‘Instances’ tab for your project on openstack.stfc.ac.uk
openstack server list
Example Output:
Using the CLI - General Tips
The following points are useful general tips for getting used to the CLI environment.
Openstack CLI commands follow a generally consistent format, see the examples below:
All openstack commands have built in documentation. Use the
--help
flag.Not all CLI components are installed by default. For example, Openstack Octavia Loadbalancer commands must be installed with the following command
Useful Links
Like Openstack, the openstackclient packages are developed and maintained by the OpenInfra Foundation, see the following links for more information:
For more information about the openstackclient: OpenStackClient — OpenStack Command Line Client 7.2.2.dev7 documentation
The source code can be found here: python-openstackclient