Set up the CLI
Install the OpenStack CLI, sign it in with an application credential, choose a region, and format its output.
This guide installs the standard openstack command line client and signs it in to your project.
The same client works with every service.
Before you begin
You need Python 3.10 or later, and an application credential for the project you want to work in.
1. Install the client
pip install python-openstackclientIf you prefer to keep command line tools isolated, install it with pipx instead:
pipx install python-openstackclientSome services add their commands through a separate package. Their CLI reference names the package
to install, and pipx inject python-openstackclient <package> adds it to a pipx installation.
2. Sign in
The client reads credentials from clouds.yaml. Add an entry for your application credential and
the region you work in:
clouds:
vexxhost:
auth_type: v3applicationcredential
auth:
auth_url: https://auth.vexxhost.net/v3
application_credential_id: 3c2b8e1f4a6d4c0e9b7a5f3d1e2c4b6a
application_credential_secret: Jq7mX2vL9pR4tW8yZ1bC5nF3hK6dS0gAuE2iO7qT4wY9rU1oP3aL6sD8fG5hJ2kZ0xC7vB4nM1qW8eR3tY6u
region_name: <region>openstack region list shows the regions. Then choose the entry for your shell:
export OS_CLOUD=vexxhostThe client finds each service in the service catalog, so it needs no other settings.
3. Choose an output format
Commands print tables by default. Commands that print a resource or a list also take the standard output options, which are useful in scripts:
| Option | Effect |
|---|---|
-f json, -f yaml | Machine-readable output. |
-f value | Values only, one row per line. |
-f shell | name="value" lines to eval, for one resource. |
-f csv | Comma-separated rows, for lists. |
-c <column> | Only this column. Repeat for more columns. |
--noindent | Compact JSON. |
--max-width <n>, --fit-width | Wrap wide tables. |
--sort-column <column> | Sort a list by a column. |
For example, this lists your projects as JSON:
openstack project list --my-projects -f json[
{
"ID": "a6f1c2d93b8e4f07b5d4e2c1a9f8e7d6",
"Name": "acme-production"
}
]Verify
openstack token issue -c project_idThe output shows the project your credential belongs to. Every command acts on that project.
Next steps
- Look up any command's options with
openstack help <command>. - Use OpenStack from Python with the same
clouds.yamlentry.