OpenStack command line clients: Difference between revisions
No edit summary |
(Marked this version for translation) |
||
Line 1: | Line 1: | ||
<languages/> | <languages/> | ||
<translate> | <translate> | ||
<!--T:1--> | |||
''Parent page: [[OpenStack]]'' | ''Parent page: [[OpenStack]]'' | ||
<!--T:2--> | |||
The OpenStack CLI tools perform many of the actions performed by the OpenStack dashboard GUI but on the command line. They also allow more functionality above and beyond the OpenStack dashboard. | The OpenStack CLI tools perform many of the actions performed by the OpenStack dashboard GUI but on the command line. They also allow more functionality above and beyond the OpenStack dashboard. | ||
The command line clients can be used from any machine, virtual or otherwise, and only require having an internet connection and the command line clients installed. The below discussion of command line client(s), assumes that they are being used on a Linux machine. It may be possible to use them in Windows however, this has not yet been explored. | The command line clients can be used from any machine, virtual or otherwise, and only require having an internet connection and the command line clients installed. The below discussion of command line client(s), assumes that they are being used on a Linux machine. It may be possible to use them in Windows however, this has not yet been explored. | ||
==Connecting CLI to OpenStack== | ==Connecting CLI to OpenStack== <!--T:3--> | ||
To begin, get the openstack environment setup file: On the OpenStack dashboard go to compute->Access & Security-> API Access-> Download OpenStack RC File. This file sets environment variables so that the command line client(s) know how to connect to your OpenStack project. Then source the file (you will need to provide your OpenStack password) with something like | To begin, get the openstack environment setup file: On the OpenStack dashboard go to compute->Access & Security-> API Access-> Download OpenStack RC File. This file sets environment variables so that the command line client(s) know how to connect to your OpenStack project. Then source the file (you will need to provide your OpenStack password) with something like | ||
{{Command | source <project name>-openrc.sh}} | {{Command | source <project name>-openrc.sh}} | ||
<!--T:4--> | |||
On East-cloud there are two RC files to choose from a v2.0 and a v3 file. Unless you have a specific reason to choose the v2.0 file, choose the v3 file. If your openstack client version is version 2.5.0 or later, the East-cloud v3 file must have the line <code>export OS_IDENTITY_API_VERSION=3</code> added to it. Finally if switching between different RC files (e.g. east and west cloud RC files) you should be careful of environment variables which may still be set from the previous RC file, these may cause your OpenStack client commands to fail. You can either ensure that all environment variables set in the RC file are unset with <code>unset <variable-name></code> commands for each variable, or start a fresh new session without any of the RC environment variables set. | On East-cloud there are two RC files to choose from a v2.0 and a v3 file. Unless you have a specific reason to choose the v2.0 file, choose the v3 file. If your openstack client version is version 2.5.0 or later, the East-cloud v3 file must have the line <code>export OS_IDENTITY_API_VERSION=3</code> added to it. Finally if switching between different RC files (e.g. east and west cloud RC files) you should be careful of environment variables which may still be set from the previous RC file, these may cause your OpenStack client commands to fail. You can either ensure that all environment variables set in the RC file are unset with <code>unset <variable-name></code> commands for each variable, or start a fresh new session without any of the RC environment variables set. | ||
==Combined OpenStack CLI == | ==Combined OpenStack CLI == <!--T:5--> | ||
The OpenStack combined CLI replaces the various separate command line tools, such as nova, swift, glance, cider etc. (see [[OpenStack Command Line Clients#Separate Command Line Clients | Separate Command Line Clients]] for a brief overview of the older separate command line clients). See for the official OpenStack [http://docs.openstack.org/developer/python-openstackclient/ CLI documentation] for more information about the OpenStack command line clients. The rest of this section gives a very basic overview to get a user started and points out some of the commands available. | The OpenStack combined CLI replaces the various separate command line tools, such as nova, swift, glance, cider etc. (see [[OpenStack Command Line Clients#Separate Command Line Clients | Separate Command Line Clients]] for a brief overview of the older separate command line clients). See for the official OpenStack [http://docs.openstack.org/developer/python-openstackclient/ CLI documentation] for more information about the OpenStack command line clients. The rest of this section gives a very basic overview to get a user started and points out some of the commands available. | ||
===Installation=== | ===Installation=== <!--T:6--> | ||
If you have admin access on the machine you will run these from (e.g. your desktop) you can do | If you have admin access on the machine you will run these from (e.g. your desktop) you can do | ||
{{commands|sudo apt-get install python-dev python-pip|sudo pip install python-openstackclient}} | {{commands|sudo apt-get install python-dev python-pip|sudo pip install python-openstackclient}} | ||
Line 22: | Line 25: | ||
<!--T:7--> | |||
Some distributions may have pre-built packages for the client, e.g., on Fedora 23: {{commands|sudo dnf install python-openstackclient}} | Some distributions may have pre-built packages for the client, e.g., on Fedora 23: {{commands|sudo dnf install python-openstackclient}} | ||
<!--T:8--> | |||
see the OpenStack [http://docs.openstack.org/cli-reference/common/cli_install_openstack_command_line_clients.html installation documentation] for more details. | see the OpenStack [http://docs.openstack.org/cli-reference/common/cli_install_openstack_command_line_clients.html installation documentation] for more details. | ||
===Executing commands=== | ===Executing commands=== <!--T:9--> | ||
The combined CLI tool can be used interactively by running | The combined CLI tool can be used interactively by running | ||
{{Command|openstack}} | {{Command|openstack}} | ||
Line 33: | Line 38: | ||
When running in interactive mode a list of available commands can be seen by typing <code>help</code> at the OpenStack prompt. The available commands are categorized by groups, many of the most commonly used groups are listed below (e.g. the <code>server</code> command group). A list of commands belonging to a command group can be obtained by typing <code>help <command group></code>. To get help on a particular command (e.g. options and arguments of the command) one can type <code>help <command group> <command></code>. Note that many of the available commands are available only to OpenStack administrators and will show some meaningless error message if a non-administrator tries using it. For this reason a list of available commands grouped by command groups is provided below to allow one to easily identify commands available to the average user. | When running in interactive mode a list of available commands can be seen by typing <code>help</code> at the OpenStack prompt. The available commands are categorized by groups, many of the most commonly used groups are listed below (e.g. the <code>server</code> command group). A list of commands belonging to a command group can be obtained by typing <code>help <command group></code>. To get help on a particular command (e.g. options and arguments of the command) one can type <code>help <command group> <command></code>. Note that many of the available commands are available only to OpenStack administrators and will show some meaningless error message if a non-administrator tries using it. For this reason a list of available commands grouped by command groups is provided below to allow one to easily identify commands available to the average user. | ||
====<code>server</code> command group==== | ====<code>server</code> command group==== <!--T:10--> | ||
{|- | {|- | ||
| <code>add security group</code> || <code>migrate</code> || <code>resume</code> || <code>unlock</code> | | <code>add security group</code> || <code>migrate</code> || <code>resume</code> || <code>unlock</code> | ||
Line 52: | Line 57: | ||
|} | |} | ||
====<code>volume</code> command group==== | ====<code>volume</code> command group==== <!--T:11--> | ||
{|- | {|- | ||
|<code>create</code>||<code>set</code> | |<code>create</code>||<code>set</code> | ||
Line 61: | Line 66: | ||
|} | |} | ||
====<code>console</code> command group==== | ====<code>console</code> command group==== <!--T:12--> | ||
{|- | {|- | ||
|<code>log show</code>||<code>url show</code> | |<code>log show</code>||<code>url show</code> | ||
Line 81: | Line 86: | ||
|} | |} | ||
====<code>ip</code> command group==== | ====<code>ip</code> command group==== <!--T:13--> | ||
{|- | {|- | ||
|<code>fixed add</code>||<code>floating list</code> | |<code>fixed add</code>||<code>floating list</code> | ||
Line 100: | Line 105: | ||
|} | |} | ||
====<code>network</code> command group==== | ====<code>network</code> command group==== <!--T:14--> | ||
{|- | {|- | ||
|<code>create</code>||<code>set</code> | |<code>create</code>||<code>set</code> | ||
Line 109: | Line 114: | ||
|} | |} | ||
====<code>snapshot</code> command group==== | ====<code>snapshot</code> command group==== <!--T:15--> | ||
{|- | {|- | ||
|<code>create</code>||<code>set</code> | |<code>create</code>||<code>set</code> | ||
Line 118: | Line 123: | ||
|} | |} | ||
====<code>security group</code> command group==== | ====<code>security group</code> command group==== <!--T:16--> | ||
{|- | {|- | ||
|<code>create</code>||<code>rule list</code> | |<code>create</code>||<code>rule list</code> | ||
Line 156: | Line 161: | ||
--> | --> | ||
==Separate Command Line Clients== | ==Separate Command Line Clients== <!--T:17--> | ||
The older version of the command line clients were separated into individual clients which operated on the various aspects of OpenStack. They are mentioned here, since, as of the time of writing, not all the functionality of the older separate command line clients has been incorporated into the new combined command line clients and one may find them useful in addition to the newer combined command line client.<!-- | The older version of the command line clients were separated into individual clients which operated on the various aspects of OpenStack. They are mentioned here, since, as of the time of writing, not all the functionality of the older separate command line clients has been incorporated into the new combined command line clients and one may find them useful in addition to the newer combined command line client.<!-- | ||
<!--T:18--> | |||
<ol> | <ol> | ||
<li> | <li> | ||
Line 170: | Line 176: | ||
</ol>--> | </ol>--> | ||
<!--T:19--> | |||
[[Category:CC-Cloud]] | [[Category:CC-Cloud]] | ||
</translate> | </translate> |
Revision as of 19:53, 6 September 2016
Parent page: OpenStack
The OpenStack CLI tools perform many of the actions performed by the OpenStack dashboard GUI but on the command line. They also allow more functionality above and beyond the OpenStack dashboard. The command line clients can be used from any machine, virtual or otherwise, and only require having an internet connection and the command line clients installed. The below discussion of command line client(s), assumes that they are being used on a Linux machine. It may be possible to use them in Windows however, this has not yet been explored.
Connecting CLI to OpenStack
To begin, get the openstack environment setup file: On the OpenStack dashboard go to compute->Access & Security-> API Access-> Download OpenStack RC File. This file sets environment variables so that the command line client(s) know how to connect to your OpenStack project. Then source the file (you will need to provide your OpenStack password) with something like
[name@server ~]$ source <project name>-openrc.sh
On East-cloud there are two RC files to choose from a v2.0 and a v3 file. Unless you have a specific reason to choose the v2.0 file, choose the v3 file. If your openstack client version is version 2.5.0 or later, the East-cloud v3 file must have the line export OS_IDENTITY_API_VERSION=3
added to it. Finally if switching between different RC files (e.g. east and west cloud RC files) you should be careful of environment variables which may still be set from the previous RC file, these may cause your OpenStack client commands to fail. You can either ensure that all environment variables set in the RC file are unset with unset <variable-name>
commands for each variable, or start a fresh new session without any of the RC environment variables set.
Combined OpenStack CLI
The OpenStack combined CLI replaces the various separate command line tools, such as nova, swift, glance, cider etc. (see Separate Command Line Clients for a brief overview of the older separate command line clients). See for the official OpenStack CLI documentation for more information about the OpenStack command line clients. The rest of this section gives a very basic overview to get a user started and points out some of the commands available.
Installation
If you have admin access on the machine you will run these from (e.g. your desktop) you can do
[name@server ~]$ sudo apt-get install python-dev python-pip
[name@server ~]$ sudo pip install python-openstackclient
To install on a machine without admin privileges (provided pip is already installed) use:
[name@server ~]$ pip install --user python-openstackclient
which installs to ~/.local/lib/pythonX.Y/site-packages/. By adding export PYTHONPATH=${HOME}/.local/lib/python2.7/site-packages/:${PYTHONPATH}
to your .bashrc
file if you are using Python major version X=2, and minor version Y=7, python can then load the OpenStack modules (see [] for information about working with the Python OpenStack API). Further adding export PATH=${HOME}/.local/bin:${PATH}
to your .bashrc will allow you to run the OpenStack commands directly. To install a specific version of the client using pip do pip install python_openstackclient==2.3.0
.
Some distributions may have pre-built packages for the client, e.g., on Fedora 23:
[name@server ~]$ sudo dnf install python-openstackclient
see the OpenStack installation documentation for more details.
Executing commands
The combined CLI tool can be used interactively by running
[name@server ~]$ openstack
and then issuing commands at the prompt. Alternatively the commands can be issued as one-offs by preceding the command with openstack
, for example
[name@server ~]$ openstack server list
When running in interactive mode a list of available commands can be seen by typing help
at the OpenStack prompt. The available commands are categorized by groups, many of the most commonly used groups are listed below (e.g. the server
command group). A list of commands belonging to a command group can be obtained by typing help <command group>
. To get help on a particular command (e.g. options and arguments of the command) one can type help <command group> <command>
. Note that many of the available commands are available only to OpenStack administrators and will show some meaningless error message if a non-administrator tries using it. For this reason a list of available commands grouped by command groups is provided below to allow one to easily identify commands available to the average user.
server
command group
add security group |
migrate |
resume |
unlock
|
add volume |
pause |
set |
unpause
|
create |
reboot |
shelve |
unrescue
|
delete |
rebuild |
show |
unset
|
dump create |
remove security group |
ssh |
unshelve
|
image create |
remove volume |
start |
|
list |
rescue |
stop
| |
lock |
resize |
suspend
|
volume
command group
create |
set
|
delete |
show
|
list |
unset
|
console
command group
log show |
url show
|
flavor
command group
list |
show
|
image
command group
create
|
save
|
delete
|
set
|
list
|
show
|
ip
command group
fixed add |
floating list
|
fixed remove |
floating pool list
|
floating add |
floating remove
|
floating create |
floating show
|
floating delete
|
keypair
command group
create |
list
|
delete |
show
|
network
command group
create |
set
|
delete |
show
|
list |
snapshot
command group
create |
set
|
delete |
show
|
list |
unset
|
security group
command group
create |
rule list
|
delete |
rule show
|
list |
set
|
rule create |
show
|
rule delete |
limits show
Separate Command Line Clients
The older version of the command line clients were separated into individual clients which operated on the various aspects of OpenStack. They are mentioned here, since, as of the time of writing, not all the functionality of the older separate command line clients has been incorporated into the new combined command line clients and one may find them useful in addition to the newer combined command line client.