OpenStack command line clients: Difference between revisions
No edit summary |
|||
(20 intermediate revisions by 7 users not shown) | |||
Line 3: | Line 3: | ||
<!--T:20--> | <!--T:20--> | ||
''Parent page: [[OpenStack]]'' | ''Parent page: [[Managing your cloud resources with OpenStack]]'' | ||
<!--T:21--> | <!--T:21--> | ||
Line 9: | Line 9: | ||
==Installation== <!--T:22--> | ==Installation== <!--T:22--> | ||
The OpenStack command lines tools are Python-based. You can install and run them on your personal computer or on a cloud VM. Different Linux distributions may have pre-built packages for the client, see the OpenStack [ | The OpenStack command lines tools are Python-based. You can install and run them on your personal computer or on a cloud VM. Different Linux distributions may have pre-built packages for the client, see the OpenStack [https://docs.openstack.org/user-guide/common/cli-install-openstack-command-line-clients.html installation documentation] for more details. You can quickly install both Python and the OpenStack command line tools, if you have administrative privileges on your machine. | ||
<!--T:38--> | |||
; Ubuntu | ; Ubuntu | ||
<pre> | <pre> | ||
Line 31: | Line 32: | ||
pip install --user python-openstackclient | pip install --user python-openstackclient | ||
</pre> | </pre> | ||
: The install location is probably already included in your <code>$PATH</code>, but you can double check whether <code>~/.bashrc</code> or <code>~/.bash_profile</code> contains the following <code>PATH=$PATH:$HOME/.local/bin:$HOME/bin</code> | : The install location is probably already included in your <code>$PATH</code>, but you can double check whether <code>~/.bashrc</code> or <code>~/.bash_profile</code> contains the following line <code>PATH=$PATH:$HOME/.local/bin:$HOME/bin</code> | ||
<!--T:23--> | <!--T:23--> | ||
Line 38: | Line 39: | ||
==Connecting CLI to OpenStack== <!--T:25--> | ==Connecting CLI to OpenStack== <!--T:25--> | ||
Your command line client must now be told how to find your OpenStack project on | Your command line client must now be told how to find your OpenStack project on our clouds. | ||
The most convenient way to do this is to download an OpenStack environment setup file. On the OpenStack dashboard go to | The most convenient way to do this is to download an OpenStack environment setup file. On the OpenStack dashboard go to Project-> API Access-> Download OpenStack RC File. | ||
<!--T:27--> | <!--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 | 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 CCDB password. Test your setup by typing {{Command |openstack image list}} | ||
<!--T:28--> | <!--T:28--> | ||
If you switch between different RC files | If you switch between different 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 155: | Line 153: | ||
|<code>rule delete</code>|| | |<code>rule delete</code>|| | ||
|} | |} | ||
===<code>limits | |||
===<code>limits</code> command group=== <!--T:37--> | |||
{|- | |||
|<code>show </code>|| | |||
|} | |||
<!--These two (container and object) are not widely publicized | <!--These two (container and object) are not widely publicized | ||
===container=== | ===container=== | ||
Line 181: | Line 183: | ||
--> | --> | ||
<!--T: | ==Separate Command-line interfaces== <!--T:40--> | ||
[[Category: | In addition to the <code>openstack</code> command described above which incorporates much of the total functionality available into one command there are also individual commands to work with the separate components of OpenStack which often have extra functionality. These separate commands are installed at the same time as the <code>openstack</code> command, as described above, so no further installation is required to use them. A list of the commands for working with common components of OpenStack are: | ||
* <code>nova</code>: for working with servers, see [https://docs.openstack.org/python-novaclient/latest/cli/nova.html OpenStack docs for nova command]. | |||
* <code>glance</code>: for working with images, see [https://docs.openstack.org/python-glanceclient/latest/cli/glance.html OpenStack docs for glance command]. | |||
* <code>cinder</code>: for working with volumes, see [https://docs.openstack.org/python-cinderclient/latest/user/shell.html OpenStack docs for cinder command]. | |||
* <code>heat</code>: for working with orchestration, see [https://docs.openstack.org/python-heatclient/latest/man/heat.html OpenStack docs for heat command]. | |||
<!--T:39--> | |||
[[Category: Cloud]] | |||
</translate> | </translate> |
Latest revision as of 15:31, 7 October 2024
Parent page: Managing your cloud resources with 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[edit]
The OpenStack command lines tools are Python-based. You can install and run them on your personal computer or on a cloud VM. Different Linux distributions may have pre-built packages for the client, see the OpenStack installation documentation for more details. You can quickly install both Python and the OpenStack command line tools, if you have administrative privileges on your machine.
- Ubuntu
sudo apt-get install python python-dev python-pip sudo pip install python-openstackclient
- CentOS 7
Run as root
yum install epel-release yum install gcc python python-dev python2-pip pip install python-openstackclient
- Fedora
sudo dnf install python-openstackclient
- Note
- If you do not have administrative privileges and cannot use the OS package manager, then you will need to install Python and pip by other means. Once installed, you can get the command line tools installed into your home space like so:
pip install --user python-openstackclient
- The install location is probably already included in your
$PATH
, but you can double check whether~/.bashrc
or~/.bash_profile
contains the following linePATH=$PATH:$HOME/.local/bin:$HOME/bin
- SDK
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.
Connecting CLI to OpenStack[edit]
Your command line client must now be told how to find your OpenStack project on our clouds. The most convenient way to do this is to download an OpenStack environment setup file. On the OpenStack dashboard go to Project-> API Access-> Download OpenStack RC File.
Then source the file with something like
[name@server ~]$ source <project name>-openrc.sh
It will ask you for your OpenStack password, which is simply your CCDB password. Test your setup by typing
[name@server ~]$ openstack image list
If you switch between different 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[edit]
The CLI tool can be used interactively by typing
[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. 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[edit]
server
command group[edit]
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[edit]
create |
set
|
delete |
show
|
list |
unset
|
console
command group[edit]
log show |
url show
|
flavor
command group[edit]
list |
show
|
image
command group[edit]
create
|
save
|
delete
|
set
|
list
|
show
|
ip
command group[edit]
fixed add |
floating list
|
fixed remove |
floating pool list
|
floating add |
floating remove
|
floating create |
floating show
|
floating delete
|
keypair
command group[edit]
create |
list
|
delete |
show
|
network
command group[edit]
create |
set
|
delete |
show
|
list |
snapshot
command group[edit]
create |
set
|
delete |
show
|
list |
unset
|
security group
command group[edit]
create |
rule list
|
delete |
rule show
|
list |
set
|
rule create |
show
|
rule delete |
limits
command group[edit]
show |
Separate Command-line interfaces[edit]
In addition to the openstack
command described above which incorporates much of the total functionality available into one command there are also individual commands to work with the separate components of OpenStack which often have extra functionality. These separate commands are installed at the same time as the openstack
command, as described above, so no further installation is required to use them. A list of the commands for working with common components of OpenStack are:
nova
: for working with servers, see OpenStack docs for nova command.glance
: for working with images, see OpenStack docs for glance command.cinder
: for working with volumes, see OpenStack docs for cinder command.heat
: for working with orchestration, see OpenStack docs for heat command.