Use the openstack CLI

Install the openstack command-line client and run commands against a project with the clouds.yaml or openrc.sh file of an application credential.

The openstack command-line client works with your project through an application credential. The console generates two files for it: clouds.yaml and openrc.sh. Use either one.

Before you begin

  • Create an application credential in the project, and download clouds.yaml or openrc.sh. See Create an application credential.
  • For your own use, a personal credential is enough. For a CI pipeline that others depend on, use a service account's credential, which keeps working when people leave.
  • You need a machine with Python 3.

Install the client

Install the openstack client
python3 -m venv ~/.venvs/openstack
. ~/.venvs/openstack/bin/activate
pip install python-openstackclient python-octaviaclient python-barbicanclient
openstack --version

The commands install the client in a Python virtual environment.

Use clouds.yaml

Copy clouds.yaml to the folder where the client looks for it, and make it readable only by you:

Install clouds.yaml
mkdir -p ~/.config/openstack
install -m 600 clouds.yaml ~/.config/openstack/clouds.yaml

Select the cloud entry from the file, which is named bulutistan:

Select the cloud
export OS_CLOUD=bulutistan

Run commands:

Run commands
openstack server list
openstack network list
openstack volume list
openstack loadbalancer list

Instead of setting OS_CLOUD, you can pass the cloud with each command: openstack --os-cloud bulutistan server list. The file already sets the region and the public interface, so you don't need to add them.

Use openrc.sh

Load the file into your shell, and run commands:

Load openrc.sh
. ./openrc.sh
openstack server list

The file sets the OS_* environment variables of the credential. It also clears project and user variables that an older openrc file can leave in the shell, because an application credential is already bound to its project and a leftover project setting makes the sign-in fail. Don't add OS_PROJECT_* variables.

Verify

Ask for a token. The command prints the ID of the project that the credential is bound to:

Check the credential
openstack token issue -c project_id -f value

If the command fails with an authentication error, check that the credential is still active in Identity & AccessOpenStack API access. See Rotate and revoke credentials.

On this page