Chapter 1: How to Setup the Openstack CLI
There are two types of Command Line Interface are currently available.
- Integreated openstack CLI (openstack cli)
- Native Client CLI for each openstack projects (nova cli, neutron cli, keystone cli, glance cli)
In this book, we covers the Native CLI.
Native CLI Client :
1. Introduction :
Client libraries are written in python. The latest openstack native clients (nova, netutron,glance,keystone) can be downloaded and installed from https://pypi.python.org.
Latest Release details(When i write this chapter):
Name | Version |
---|---|
Nova client | 9.1.0 |
Neutron client | 6.5.0 |
Keystone Client | 3.13.0 |
Glance Client | 2.8.0 |
2. Where to install:
- The installation machine should have the network access to openstack nodes(keystone, nova, netutron,etc).
- Preferablly linux machine
3. How to install :
Its always prefer to install the clients in python virtual env.
step1: Install the python virtual env,
sudo apt-get install python-virtualenv python-dev build-essential libssl-dev libffi-dev
step2: create the virtualenv in your home folder
virtualenv osclient
step3: Activate the virtual env
. osclient/bin/activate
step4: Install the nova,neutron,keystone clients
pip install python-novaclient==9.1.0
pip install python-neutronclient==6.5.0
pip install python-keystoneclient==3.13.0
pip install python-glanceclient==2.8.0
4. Verify the version :
Use "--version" flag to verify the version.
Example:
neutron --version
5. How to use:
- Download the openstack creds(Compute-> API Access -> Download Openstack RC File v2.0) from openstack horizon. (or) export the openstack creds in shell variables (refer here). (or) Copy the openrc file from your openstack or devstack installation.
source the file
source openrc
Note: You may asked for password, if you download it from Horizon.
Execute the sample nova/neutron CLI commands
neutron net-list nova list
Execution Logs:
Create & activate the virtual env
cloud@db:~$ virtualenv osclient
New python executable in osclient/bin/python
Installing setuptools, pip...done.
cloud@db:~$ cd osclient/
cloud@db:~/osclient$ . bin/activate
(osclient)cloud@db:~/osclient$
Execute the neutron,nova commands
(osclient)cloud@db:~/osclient$ neutron net-list neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+---------+----------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+---------+----------------------------------------------------------+
| 166d0427-cfc5-4234-b61c-b3bb8f6e3a32 | private | 91c773a1-a4e2-4f14-946d-401c1f7ee627 10.0.0.0/26 |
| | | dea60d2b-6809-43eb-a687-d1877e04f679 fd25:cc32:b8d7::/64 |
| 975dd3d1-3576-4c34-991e-eaf24f45295e | public | 8171e8c6-2953-4ffa-beab-8f07b43a08c4 |
| | | 543ef8a3-5717-44d1-81f9-70c5057e889c |
| b58f56b1-74f4-4aad-b210-8b57b1794889 | N1 | 80f75a4e-3023-42e8-8eef-701be6820af3 10.10.10.0/24 |
+--------------------------------------+---------+----------------------------------------------------------+
(osclient)cloud@db:~/osclient$ nova list
+--------------------------------------+------+--------+------------+-------------+----------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+----------------------------+
| 1d6de82e-69ff-41aa-87bf-4977d32cd02d | vm1 | ACTIVE | - | Running | N1=10.10.10.10, 172.24.4.7 |
+--------------------------------------+------+--------+------------+-------------+----------------------------+
(osclient)cloud@db:~/osclient$