OpenStack Client is a command-line tool for OpenStack that brings the command set for Compute, Identity, Image, Object Storage and Block Storage APIs together in a single shell with a uniform command structure. The OpenStack client enables you to interact with OpenStack services over the network via API call.
A pre-requisite for this setup is a working OpenStack Cloud platform. You can check our OpenStack guides for how to articles. If you’re a developer and would like to contribute, the code is hosted on OpenStack’s Git server.
OpenStack Installation guide: Install OpenStack Victoria on CentOS 8 With Packstack
Step 1: Install Python Pip tool
Some Linux distributions include packaged versions of the OpenStack command-line clients that you can install directly, but we’ll install from Pip. Install pip through the package manager for your system:
### Install pip on Debian / Ubuntu ###
sudo apt update
#Python3
sudo apt install python3-dev python3-pip
sudo pip3 install --upgrade pip
#Python2
sudo apt install python-dev python-pip
sudo pip install --upgrade pip
### Install pip on CentOS / RHEL ###
#Python3
sudo yum -y install python3-devel python3-pip
sudo pip3 install --upgrade pip
#Python2
sudo yum -y install python-devel python-pip
sudo pip install --upgrade pip
### Install pip on Arch / Manjaro ###
sudo pacman -Syy
sudo pacman -S python-pip
sudo pip install --upgrade pip
### Install pip on macOS ###
sudo easy_install pip
Confirm version of pip installed.
#Python3
$ pip3 --version
pip 21.3.1 from /usr/local/lib/python3.9/dist-packages/pip (python 3.9)
#Python2
$ pip --version
Step 2: Install OpenStack Client on Linux
After installation of Pip, proceed to install OpenStack command-line clients.
#Python3
sudo pip3 install python-openstackclient
#Python2
sudo pip install python-openstackclient
Display more information about installed Openstack Command Line client.
$ pip show python-openstackclient
$ pip3 show python-openstackclient
Name: python-openstackclient
Version: 5.7.0
Summary: OpenStack Command-line Client
Home-page: https://docs.openstack.org/python-openstackclient/latest/
Author: OpenStack
Author-email: [email protected]
License: UNKNOWN
Location: /usr/local/lib/python3.9/dist-packages
Requires: cliff, iso8601, openstacksdk, osc-lib, oslo.i18n, oslo.utils, pbr, python-cinderclient, python-keystoneclient, python-novaclient, stevedore
Required-by:
You should have openstack command in your PATH.
$ which openstack
/usr/local/bin/openstack
Step 3: Configure OpenStack Client on Linux
You can pull OpenStack configuration file from OpenStack Director or create one if you have correct access credentials.
$ vim ~/.keystonerc
unset OS_SERVICE_TOKEN
export OS_USERNAME='admin'
export OS_PASSWORD='adminpassword'
export OS_AUTH_URL=http://192.168.100.10:5000/v3
export PS1='[\u@\h \W(keystone_admin)]\$ '
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
Update variables to match your OpenStack environment. When done, source the file to start using openstack command line tool to administer OpenStack Cloud.
$ source ~/.keystonerc
Your Shell prompt should change to.
[\u@\h \W(keystone_admin)]$
Run openstack command to confirm it is working.
[\u@\h \W(keystone_admin)]$ openstack network list
+--------------------------------------+---------------------------+----------------------------------------------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+---------------------------+----------------------------------------------------------------------------+
| 900b1ede-3e62-4d73-88d3-b28c129a6bb6 | public | c1770934-54bb-4252-928a-c7a41c6e114a |
| da22131e-0b50-46e7-8d35-b18bbb161f1b | mycluster-lww6p-openshift | 6770ab86-2481-46e6-8d29-ab3c6a82b6cc, ec91b5c4-37fd-453f-be02-9ee8327654c2 |
| e406e76f-e89d-42a2-bab1-9c883b2e49aa | private | 76ff61dd-0438-4848-a611-f4b4de070164 |
+--------------------------------------+---------------------------+----------------------------------------------------------------------------+
$ openstack image list
+--------------------------------------+---------------------+--------+
| ID | Name | Status |
+--------------------------------------+---------------------+--------+
| 0850ee38-1bdf-4379-9c69-0cf73e8b7c65 | Arch-Linux-x86_64 | active |
| e98445b6-f14f-488c-a18a-1f66c6de15c7 | CentOS-7-x86_64 | active |
| 7b4b616e-71f3-4419-9777-7aee66fad62c | Cirros-0.4.0-x86_64 | active |
| 8514fea0-3d55-4248-a79f-5c0183f95898 | CoreOS-x86_64 | active |
| 98bbd9e6-abbc-45fa-ac95-b91b7b18ba0a | Debian-9-amd64 | active |
| 113b90b6-4e1e-4715-b9ab-456c191a82b3 | Fedora-30-x86_64 | active |
| 06c17e8a-0d4c-428a-89b5-b0eb2489f403 | Ubuntu-16.04-x86_64 | active |
| 2ba79fa6-2434-4dc6-ad86-0baf29d44c79 | rhcos | active |
| c3bb11c7-81af-49fe-a26c-a60e9b14585c | rhcos-kvm | active |
+--------------------------------------+---------------------+--------+
Step 4: Enable OpenStack Bash completion
Use the openstack complete command to generate a bash-completion script.
openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion > /dev/null
Logout
$ logout
or
$ exit
Then login again to enjoy OpenStack bash completion.
$ openstack network
agent create flavor log meter rbac service show trunk
auto delete list loggable qos segment set subport unset
You have learned how to install and configure OpenStack client on a Linux system.