OpenStack command line clients: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
(copyediting, section reordering,)
(Marked this version for translation)
Line 2: Line 2:
<translate>
<translate>


<!--T:20-->
''Parent page: [[OpenStack]]''
''Parent page: [[OpenStack]]''


<!--T:21-->
The [http://docs.openstack.org/developer/python-openstackclient/ OpenStack command line tool] allows you to perform many of the actions provided by the OpenStack dashboard GUI, as well as providing some functionality which the dashboard does not. The command line client can be used from any machine, virtual or otherwise, and only requires having an internet connection and the client installed. The discussion below assumes that it is being used on a Linux machine.
The [http://docs.openstack.org/developer/python-openstackclient/ OpenStack command line tool] allows you to perform many of the actions provided by the OpenStack dashboard GUI, as well as providing some functionality which the dashboard does not. The command line client can be used from any machine, virtual or otherwise, and only requires having an internet connection and the client installed. The discussion below assumes that it is being used on a Linux machine.


==Installation==
==Installation== <!--T:22-->
If you have administrative privileges on the machine you will run these from (e.g. your desktop) you can do
If you have administrative privileges 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 12: Line 14:
which installs to <code>~/.local/lib/pythonX.Y/site-packages/</code>. You may wish to add <code>export PATH=${HOME}/.local/bin:${PATH}</code> to your <code>.bashrc</code> file in this case so you can run the OpenStack commands directly.
which installs to <code>~/.local/lib/pythonX.Y/site-packages/</code>. You may wish to add <code>export PATH=${HOME}/.local/bin:${PATH}</code> to your <code>.bashrc</code> file in this case so you can run the OpenStack commands directly.


<!--T:23-->
If you wish to explore the [http://docs.openstack.org/user-guide/sdk.html OpenStack API for Python], add <code>export PYTHONPATH=${HOME}/.local/lib/python2.7/site-packages/:${PYTHONPATH}</code> to your <code>.bashrc</code> file. Adjust the <code>python2.7</code> phrase to match the Python version you have installed.
If you wish to explore the [http://docs.openstack.org/user-guide/sdk.html OpenStack API for Python], add <code>export PYTHONPATH=${HOME}/.local/lib/python2.7/site-packages/:${PYTHONPATH}</code> to your <code>.bashrc</code> file. Adjust the <code>python2.7</code> phrase to match the Python version you have installed.


<!--T:24-->
Some Linux distributions may have pre-built packages for the client, e.g., on Fedora 23: {{command|sudo dnf install python-openstackclient}}
Some Linux distributions may have pre-built packages for the client, e.g., on Fedora 23: {{command|sudo dnf install python-openstackclient}}
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.


==Connecting CLI to OpenStack==
==Connecting CLI to OpenStack== <!--T:25-->
Your command line client must now be told how to find your OpenStack project on the CC-Cloud.  
Your command line client must now be told how to find your OpenStack project on the CC-Cloud.  
The most convenient way to do this is to download an OpenStack environment setup file. On the OpenStack dashboard go to Compute-> Access & Security-> API Access-> Download OpenStack RC File.  
The most convenient way to do this is to download an OpenStack environment setup file. On the OpenStack dashboard go to Compute-> Access & Security-> API Access-> Download OpenStack RC File.  


<!--T:26-->
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 v2.0, choose v3. If your OpenStack client version is version 2.5.0 or later, you will have to add the line <code>export OS_IDENTITY_API_VERSION=3</code> to the East-cloud v3 file.  
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 v2.0, choose v3. If your OpenStack client version is version 2.5.0 or later, you will have to add the line <code>export OS_IDENTITY_API_VERSION=3</code> to the East-cloud v3 file.  


<!--T:27-->
Then source the file with something like {{Command |source <project name>-openrc.sh}} It will ask you for your OpenStack password, which is simply your CC-Cloud password. Test your setup by typing {{Command |openstack image list}}
Then source the file with something like {{Command |source <project name>-openrc.sh}} It will ask you for your OpenStack password, which is simply your CC-Cloud password. Test your setup by typing {{Command |openstack image list}}


<!--T:28-->
If you switch 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. Either ensure that all environment variables set in the RC file are unset with <code>unset <variable-name></code>, or start a fresh new session without any of the RC environment variables set.
If you switch 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. Either ensure that all environment variables set in the RC file are unset with <code>unset <variable-name></code>, or start a fresh new session without any of the RC environment variables set.


==Executing commands==  
==Executing commands== <!--T:29-->
The CLI tool can be used interactively by typing
The CLI tool can be used interactively by typing
{{Command|openstack}}
{{Command|openstack}}
Line 34: Line 41:
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. 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 commands are available only to OpenStack administrators and will return an 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. 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 commands are available only to OpenStack administrators and will return an 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.


==Command groups==
==Command groups== <!--T:30-->
===<code>server</code> command group===
===<code>server</code> command group===
{|-
{|-
Line 54: Line 61:
|}
|}


===<code>volume</code> command group===
===<code>volume</code> command group=== <!--T:31-->
{|-
{|-
|<code>create</code>||<code>set</code>
|<code>create</code>||<code>set</code>
Line 63: Line 70:
|}
|}


===<code>console</code> command group===
===<code>console</code> command group=== <!--T:32-->
{|-
{|-
|<code>log show</code>||<code>url show</code>
|<code>log show</code>||<code>url show</code>
Line 83: Line 90:
|}
|}


===<code>ip</code> command group===
===<code>ip</code> command group=== <!--T:33-->
{|-
{|-
|<code>fixed add</code>||<code>floating list</code>
|<code>fixed add</code>||<code>floating list</code>
Line 102: Line 109:
|}
|}


===<code>network</code> command group===
===<code>network</code> command group=== <!--T:34-->
{|-
{|-
|<code>create</code>||<code>set</code>
|<code>create</code>||<code>set</code>
Line 111: Line 118:
|}
|}


===<code>snapshot</code> command group===
===<code>snapshot</code> command group=== <!--T:35-->
{|-
{|-
|<code>create</code>||<code>set</code>
|<code>create</code>||<code>set</code>
Line 120: Line 127:
|}
|}


===<code>security group</code> command group===
===<code>security group</code> command group=== <!--T:36-->
{|-
{|-
|<code>create</code>||<code>rule list</code>
|<code>create</code>||<code>rule list</code>
Line 158: Line 165:
-->
-->


<!--T:37-->
[[Category:CC-Cloud]]
[[Category:CC-Cloud]]
</translate>
</translate>

Revision as of 20:15, 26 September 2016

Other languages:

Parent page: OpenStack

The OpenStack command line tool allows you to perform many of the actions provided by the OpenStack dashboard GUI, as well as providing some functionality which the dashboard does not. The command line client can be used from any machine, virtual or otherwise, and only requires having an internet connection and the client installed. The discussion below assumes that it is being used on a Linux machine.

Installation

If you have administrative privileges 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 administrative privileges (provided pip is already installed) use:

Question.png
[name@server ~]$  pip install --user python-openstackclient

which installs to ~/.local/lib/pythonX.Y/site-packages/. You may wish to add export PATH=${HOME}/.local/bin:${PATH} to your .bashrc file in this case so you can run the OpenStack commands directly.

If you wish to explore the OpenStack API for Python, add export PYTHONPATH=${HOME}/.local/lib/python2.7/site-packages/:${PYTHONPATH} to your .bashrc file. Adjust the python2.7 phrase to match the Python version you have installed.

Some Linux distributions may have pre-built packages for the client, e.g., on Fedora 23:

Question.png
[name@server ~]$ sudo dnf install python-openstackclient

See the OpenStack installation documentation for more details.

Connecting CLI to OpenStack

Your command line client must now be told how to find your OpenStack project on the CC-Cloud. The most convenient way to do this is to download an OpenStack environment setup file. On the OpenStack dashboard go to Compute-> Access & Security-> API Access-> Download OpenStack RC File.

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 v2.0, choose v3. If your OpenStack client version is version 2.5.0 or later, you will have to add the line export OS_IDENTITY_API_VERSION=3 to the East-cloud v3 file.

Then source the file with something like

Question.png
[name@server ~]$ source <project name>-openrc.sh

It will ask you for your OpenStack password, which is simply your CC-Cloud password. Test your setup by typing

Question.png
[name@server ~]$ openstack image list

If you switch 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. Either ensure that all environment variables set in the RC file are unset with unset <variable-name>, or start a fresh new session without any of the RC environment variables set.

Executing commands

The CLI tool can be used interactively by typing

Question.png
[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

Question.png
[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. 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 commands are available only to OpenStack administrators and will return an 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.

Command groups

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