Documentation

Documentation for the OpenStack CLI (also referred to as the OpenStackClient) is available online. OpenStack frequently releases new versions of their software, and it is important to find the documentation that corresponds to the release you installed. This can be difficult because the documentation always refers to releases by their alphabetical code names while the software reports its version numerically (use the command openstack --version.

This list of release names and numbers can help you sort things out. If you get an error message when using a command as you saw it in the documentation, consult this list of backward incompatible changes that have been made over the years to see if the command has changed.

Executables

The OpenStack CLI is invoked primarily through the openstack executable. In the past, each section of the OpenStack API had its own CLI executable, but most of those have been folded into the top-level client and are now obsolete. A few CLI executables, like Cinder (for block storage) and Nova (for the compute service) are still included in installations of openstack-client. You can use these commands if you desire, but it is recommended that you migrate your work to using the commands that are available through the openstack command.

Commands

The openstack command accepts a large number of options and arguments. The arguments constitute sub-commands that specify what the CLI should do. Many sub-commands introduce additional options that are specific to that command. Issue the command openstack --help to see overall usage information, including lengthy lists of options and arguments.

CLI commands typically take the form:

openstack NOUN VERB PARAMETERS

where action VERB is performed on entities of type NOUN with additional details being provided as PARAMETERS, if necessary. For example, the following two commands list all images and show details about an image named "My Image" (names with spaces should be quoted):


openstack image list
openstack image show "My Image"

A command of the form openstack help NOUN will print a list of all command VERBs that pertain to entities of type NOUN. A command of the form openstack help NOUN VERB will print detailed information about the options and arguments that relate to that specific NOUN-VERB operation.

Online documentation for individual sub-commands can also be helpful when you are first learning to use them. From this documentation you will quickly see that OpenStack is a large and complex software system, and the CLI does not attempt to mask that by presenting a simple interface. The CLI provides as much access as possible to the underlying API functionality, and for that reason you would do well to study the structure of the OpenStack API a bit before attempting to use the CLI.

Options

The openstack command has quite a few options that might be useful to you. Here are a few that are helpful:

Option Purpose
--version Prints the version number of the CLI that is running. You can also print version numbers for some CLI components using options like --os-compute-api-version (for the compute API).
--verbose, -v Increases the verbosity of the command output. This can be useful when debugging problems.
--quiet, -q Suppresses command output except warnings and errors.
--log-file LOG_FILE Names a file into which command output will be logged.
--fit-width This option is available for some CLI commands that print tabular output. The output columns are scaled to fit the terminal width and text is wrapped within each column. This makes output more readable, but often harder to copy for pasting. If you always want this feature enabled, include the line: export CLIFF_FIT_WIDTH=1 in your .bashrc or openrc.sh files.
Interactive Mode

If you run the openstack command without supplying any sub-command, you will enter an interactive mode, as described at the OpenStack site. While in interactive mode, your prompt will change to "(openstack)". You can now enter subcommands directly at the prompt without having to supply the "openstack" command each time. Individual sub-commands may complete more quickly in this mode because the authentication for the openstack command remains in effect and does not need to be performed again for each sub-command. Enter exit to terminate the interactive mode.

Interactive mode can be helpful when you want to invoke CLI commands from within scripts. To perform a number of CLI commands in a row, pipe them as input to a single, argument-free openstack command. In this short example, a script executes commands to list the key pairs and flavors in a project.


#!/usr/bin/bash
openstack << EOF
keypair list
flavor list
EOF
 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement