The OpenStack CLI¶
Overview¶
OpenStack consists of numerous open source projects (not OpenStack projects) that are tied together to create an OpenStack platform. Various projects can be chosen during a deployment, so OpenStack is incredibly flexible, and can become extremely complex, with the more projects included. This is a very open source methodology, similar to the method behind building a kernel, where you can pick and choose various components to include in the kernel, leaving out unnecessary code if you choose.
Each project has its own CLI, which can typically be used independently, but this model is slowly going away in favor of the consolidated CLI, where all projects’ commands are added as plugins. We will only refer to this consolidated CLI (called the OpenStack Client, or OSC).
Command structure¶
The OSC is very logical in its command structure. Generally, you will find that commands are structured like this:
openstack <object> <verb>
For example, this command returns a list of all servers in your project:
openstack server list
Verbs typically include your standard CRUD (Create/Read/Update/Delete) functions:
create
add
list
show
set
unset
delete
remove
However, you will find that some commands have rare command-specific verbs, such as:
openstack server resize
Also, note that there is a fine distinction between “create” and “add”. The “create” verb refers to creating an object, whereas “add” refers to adding an object to another object. For example, you may want to add a port to a server, so you would use:
openstack server add port
To view the help for any command, simply add –help to the command line, such as:
openstack server list --help
Most commands will provide help if you do not provide arguments, giving you a quick list of arguments you can use with the command, such as:
openstack server create
All commands available can be listed using this command. We pipe the command to “less” since the list is quite long:
openstack --help | less
Installing the OpenStack CLI¶
We have already done this in the jump host we provided you, but if you need to install the tools on a different machine (Linux only), run the following as root (or sudo to root):
CentOS 7:
cat << EOF > ./install_python.sh
# Install Python and PIP (package manager for Python applications)
if ! grep -q "export PATH" .bashrc
then
echo "export PATH=$PATH:/usr/local/bin" >> .bashrc
fi
# Install Python 3.6
yum makecache
yum -y install yum-utils
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum makecache
yum -y install python3-devel gcc gcc-c++ make libXext-devel
python3.6 -V
pip3 -V
EOF
cat << EOF > ./install_openstack_cli.sh
# Then install all Python 3.6 packages
pip3 --no-cache-dir install python-openstackclient
pip3 --no-cache-dir install python-barbicanclient
pip3 --no-cache-dir install python-cinderclient
pip3 --no-cache-dir install python-designateclient
pip3 --no-cache-dir install python-neutronclient
pip3 --no-cache-dir install python-swiftclient
pip3 --no-cache-dir install python-novaclient
pip3 --no-cache-dir install python-heatclient
pip3 --no-cache-dir install python-octaviaclient
pip3 --no-cache-dir install python-cloudkittyclient
pip3 --no-cache-dir install gnocchiclient
pip3 --no-cache-dir install python-magnumclient
pip3 --no-cache-dir install python-monascaclient
EOF
chmod 700 ./install_python.sh
chmod 700 ./install_openstack_cli.sh
./install_python.sh
./install_openstack_cli.sh
Ubuntu:
cat << EOF > ./install_python.sh
# Install Python 3.7
apt update
apt -y upgrade
apt-get -y install python3-pip
python3 -V
pip3 -V
EOF
cat << EOF > ./install_openstack_cli.sh
# Then install all Python 3.7 packages
pip3 --no-cache-dir install python-openstackclient
pip3 --no-cache-dir install python-barbicanclient
pip3 --no-cache-dir install python-cinderclient
pip3 --no-cache-dir install python-designateclient
pip3 --no-cache-dir install python-neutronclient
pip3 --no-cache-dir install python-swiftclient
pip3 --no-cache-dir install python-novaclient
pip3 --no-cache-dir install python-heatclient
pip3 --no-cache-dir install python-octaviaclient
pip3 --no-cache-dir install python-cloudkittyclient
pip3 --no-cache-dir install gnocchiclient
pip3 --no-cache-dir install python-magnumclient
pip3 --no-cache-dir install python-monascaclient
EOF
chmod 700 ./install_python.sh
chmod 700 ./install_openstack_cli.sh
./install_python.sh
./install_openstack_cli.sh