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.yamloropenrc.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
python3 -m venv ~/.venvs/openstack
. ~/.venvs/openstack/bin/activate
pip install python-openstackclient python-octaviaclient python-barbicanclient
openstack --versionThe 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:
mkdir -p ~/.config/openstack
install -m 600 clouds.yaml ~/.config/openstack/clouds.yamlSelect the cloud entry from the file, which is named bulutistan:
export OS_CLOUD=bulutistanRun commands:
openstack server list
openstack network list
openstack volume list
openstack loadbalancer listInstead 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:
. ./openrc.sh
openstack server listThe 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:
openstack token issue -c project_id -f valueIf the command fails with an authentication error, check that the credential is still active in Identity & AccessOpenStack API access. See Rotate and revoke credentials.