2013-01-31 19:30:25 -06:00
|
|
|
========
|
|
|
|
Commands
|
|
|
|
========
|
|
|
|
|
2013-07-29 17:05:02 -05:00
|
|
|
|
2013-01-31 19:30:25 -06:00
|
|
|
Command Structure
|
|
|
|
=================
|
|
|
|
|
2013-07-29 17:05:02 -05:00
|
|
|
OpenStackClient has a consistent and predictable format for all of its commands.
|
2013-01-31 19:30:25 -06:00
|
|
|
|
|
|
|
Commands take the form::
|
|
|
|
|
2013-12-05 13:23:44 -06:00
|
|
|
openstack [<global-options>] <object-1> <action> [<object-2>] [<command-arguments>]
|
2013-07-29 17:05:02 -05:00
|
|
|
|
2013-12-05 13:23:44 -06:00
|
|
|
* All long options names begin with two dashes ('--') and use a single dash
|
|
|
|
('-') internally between words (--like-this). Underscores ('_') are not used
|
|
|
|
in option names.
|
2013-07-29 17:05:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
Global Options
|
|
|
|
--------------
|
|
|
|
|
2013-12-05 13:23:44 -06:00
|
|
|
Global options are global in the sense that they apply to every command
|
|
|
|
invocation regardless of action to be performed. They include authentication
|
|
|
|
credentials and API version selection. Most global options have a corresponding
|
|
|
|
environment variable that may also be used to set the value. If both are
|
|
|
|
present, the command-line option takes priority. The environment variable
|
|
|
|
names are derived from the option name by dropping the leading dashes ('--'),
|
|
|
|
converting each embedded dash ('-') to an underscore ('_'), and converting
|
|
|
|
to upper case.
|
2013-07-29 17:05:02 -05:00
|
|
|
|
|
|
|
For example, ``--os-username`` can be set from the environment via ``OS_USERNAME``.
|
|
|
|
|
|
|
|
|
|
|
|
Command Object(s) and Action
|
|
|
|
----------------------------
|
2013-01-31 19:30:25 -06:00
|
|
|
|
2013-12-05 13:23:44 -06:00
|
|
|
Commands consist of an object described by one or more words followed by
|
|
|
|
an action. Commands that require two objects have the primary object ahead
|
|
|
|
of the action and the secondary object after the action. Any positional
|
|
|
|
arguments identifying the objects shall appear in the same order as the
|
|
|
|
objects. In badly formed English it is expressed as "(Take) object1
|
|
|
|
(and perform) action (using) object2 (to it)."
|
2013-01-31 19:30:25 -06:00
|
|
|
|
2013-07-29 17:05:02 -05:00
|
|
|
::
|
|
|
|
|
|
|
|
<object-1> <action> <object-2>
|
|
|
|
|
|
|
|
Examples::
|
|
|
|
|
|
|
|
group add user <group> <user>
|
|
|
|
|
|
|
|
volume type list # 'volume type' is a two-word single object
|
|
|
|
|
|
|
|
|
|
|
|
Command Arguments and Options
|
|
|
|
-----------------------------
|
|
|
|
|
2013-12-05 13:23:44 -06:00
|
|
|
Each command may have its own set of options distinct from the global options.
|
|
|
|
They follow the same style as the global options and always appear between
|
|
|
|
the command and any positional arguments the command requires.
|
2013-01-31 19:30:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
Implementation
|
|
|
|
==============
|
|
|
|
|
2013-12-05 13:23:44 -06:00
|
|
|
The command structure is designed to support seamless addition of plugin
|
|
|
|
command modules via ``setuptools`` entry points. The plugin commands must
|
|
|
|
be subclasses of Cliff's command.Command object.
|
2013-01-31 19:30:25 -06:00
|
|
|
|
2013-07-29 17:05:02 -05:00
|
|
|
|
2013-01-31 19:30:25 -06:00
|
|
|
Command Entry Points
|
|
|
|
--------------------
|
|
|
|
|
2013-12-05 13:23:44 -06:00
|
|
|
Commands are added to the client using ``setuptools`` entry points in ``setup.cfg``.
|
2013-01-31 19:30:25 -06:00
|
|
|
There is a single common group ``openstack.cli`` for commands that are not versioned,
|
|
|
|
and a group for each combination of OpenStack API and version that is
|
|
|
|
supported. For example, to support Identity API v3 there is a group called
|
|
|
|
``openstack.identity.v3`` that contains the individual commands. The command
|
|
|
|
entry points have the form::
|
|
|
|
|
2013-07-05 22:30:54 -04:00
|
|
|
verb_object = fully.qualified.module.vXX.object:VerbObject
|
2013-01-31 19:30:25 -06:00
|
|
|
|
|
|
|
For example, the 'list user' command fir the Identity API is identified in
|
2013-07-05 22:30:54 -04:00
|
|
|
``setup.cfg`` with::
|
2013-01-31 19:30:25 -06:00
|
|
|
|
2013-07-05 22:30:54 -04:00
|
|
|
openstack.identity.v3 =
|
2013-01-31 19:30:25 -06:00
|
|
|
# ...
|
2013-07-05 22:30:54 -04:00
|
|
|
list_user = openstackclient.identity.v3.user:ListUser
|
2013-01-31 19:30:25 -06:00
|
|
|
# ...
|