Ramblings of Linux openstack & ceph

Get Started With OpenStack Python-client

| Comments

In this post we look at how to manage them using the command line tools.

First we need to install the openstack python clients, You will need a Linux instance with root access for this - I used ubuntu 14.04

1
for i in nova keystone neutron heat cinder glance ; do sudo apt-get install python-${i}client -y ; done

Now we need to create a credentials / RC file - This will pre set a number of environment variables for later use - Fill in the when creating this file by referencing the API section of horizion Compute>Access & Security>API Access

1
2
3
4
5
export OS_TENANT_NAME="Project-XXX"
export OS_TENANT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
export OS_AUTH_URL=https://api.openstack.ecloud.co.uk:5000/v2.0
export OS_USERNAME="User.Name"
export OS_PASSWORD="myreallysecurepassword"

Now we just source the credentials / RC file - The below assumes you called the file my.rc

1
source ./my.rc

Now we can start to make use of the python packages we have installed - the below are a few examples to get you started, but you should run the commands with no arguments to view the help pages and explore the possibilities.

  • List instances
1
2
3
4
5
6
# nova list
+--------------------------------------+------------------+--------+------------+-------------+------------------------------+
| ID                                   | Name             | Status | Task State | Power State | Networks                     |
+--------------------------------------+------------------+--------+------------+-------------+------------------------------+
| 4d915206-d10b-40e8-8afe-58e94584d964 | test             | ACTIVE | -          | Running     | 1=10.0.13.220                |
+--------------------------------------+------------------+--------+------------+-------------+------------------------------+
  • List Images
1
2
3
4
5
6
7
8
9
10
11
# glance image-list
+--------------------------------------+-----------------------+-------------+------------------+-------------+--------+
| ID                                   | Name                  | Disk Format | Container Format | Size        | Status |
+--------------------------------------+-----------------------+-------------+------------------+-------------+--------+
| b4fd5649-6566-4364-a3e7-a972430e13b0 | CentOS6_2015-08       | raw         | bare             | 8388608000  | active |
| 365e993a-8827-4df5-b97c-1a535b72bd65 | CentOS7_2015-08-r2    | raw         | bare             | 8388608000  | active |
| 2e5ecdd3-0d37-4907-a713-ed09430cef14 | Debian8_2015-08       | raw         | bare             | 3145728000  | active |
| 695aca24-33ec-400b-9a87-fc8d6288e4ba | Ubuntu1404_2015-08    | raw         | bare             | 3145728000  | active |
| ce725b17-eb27-4922-b564-2c50b2bed548 | Windows2008R2_2015-09 | raw         | bare             | 32212254720 | active |
| 4adce14a-98df-471d-9fa6-cd5ad1e39e21 | Windows2012R2_2015-09 | raw         | bare             | 21474836480 | active |
+--------------------------------------+-----------------------+-------------+------------------+-------------+--------+
  • List Volume
1
2
3
4
5
6
# cinder list
+--------------------------------------+-----------+---------------+------+-----------------+----------+--------------------------------------+
|                  ID                  |   Status  |      Name     | Size |   Volume Type   | Bootable |             Attached to              |
+--------------------------------------+-----------+---------------+------+-----------------+----------+--------------------------------------+
| ea65435b-13f6-4a0f-a38f-baadf2fb99ea | available |      None     |  40  |       None      |   true   |                                      |
+--------------------------------------+-----------+---------------+------+-----------------+----------+--------------------------------------+

Comments