openstack nova python api

By | 23rd March 2014

Exploring the python nova api/commands….

The easiest way to the learn Openstack api is to use the devstack.

Install the devstack on an Ubuntu machine(I have a 13.10 where devstack is running and an LTS 12.05 where I have installed my Nova client)

1. GIT Clone using the command

git clone https://github.com/openstack-dev/devstack.git

2. Once done there will be a dev stack folder.

:~/devstack$ ls
accrc     driver_certs  exercises    files        key.pem  localrc    rejoin-stack.sh  stackrc         tests
AUTHORS   eucarc        exercise.sh  functions    lib      openrc     run_tests.sh     stack-screenrc  tools
clean.sh  exerciserc    extras.d     HACKING.rst  LICENSE  README.md  samples          stack.sh        unstack.sh

3. Run ./Stack.sh   and  Openstack it is up and running. (easy !!)

4. Exploring the python api

Install the python nova api using git

Easy to install . On my Ubuntu 12.04 (LTS) using pip

#sudo aptitude install python-novaclient

Once installation is done now we can update the .bashrc

Use vi and update the .bashrc (Go to the end of .bashrc and update the following lines)

:#vi .bashrc

OS_USERNAME=admin
OS_PASSWORD=password
OS_AUTH_URL=http://192.168.140.133:5000/v2.0
OS_NO_CACHE=1
OS_TENANT_NAME=demo
export OS_USERNAME  OS_PASSWORD OS_AUTH_URL OS_NO_CACHE OS_TENANT_NAME

Once this is done, we need to reload the .bashrc using ‘source’ command

:~# source ~/.bashrc

Now check whether the commands are working ..

As you can see below it is working now .. The same will be visible in the Openstack GUI..

:~# nova flavor-list
+—-+———–+———–+——+———–+——+——-+————-+———–+————-+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+—-+———–+———–+——+———–+——+——-+————-+———–+————-+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      | {}          |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      | {}          |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      | {}          |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      | {}          |
| 42 | m1.nano   | 64        | 0    | 0         |      | 1     | 1.0         | True      | {}          |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      | {}          |
| 84 | m1.micro  | 128       | 0    | 0         |      | 1     | 1.0         | True      | {}          |
+—-+———–+———–+——+———–+——+——-+————-+———–+————-+
:~#

Few things to remember ..

Username and password should be correct ..

The tenant name for devstack is demo. If you are using other public cloud “HP”, Rackspace or others then it will depend on Cloud account number (atleast for rackspace)..

References:

Rackspace information:(good information on the various fields)

http://www.rackspace.com/knowledge_center/article/installing-python-novaclient-on-linux-and-mac-os

Devstack: http://devstack.org/

Leave a Reply

Your email address will not be published. Required fields are marked *