Openstack Juno – Management interfaces

This blog is part of my series on Openstack Juno. In this blog, I will cover different management interfaces to Openstack. Following are the different management interfaces available.

  • Horizon web interface
  • CLI interface to each service. CLI interface is provided by Python script. Internally, the script calls the REST interface.
  • REST interface. This is accessible either through Curl or a POSTMAN kind of client.
  • Programmatic interface using Python SDK.

Horizon interface:

On the host where stacking is done, webserver runs on port 80 and all Openstack services can be configured using this interface. Login to Horizon can be done with either tenant userid or admin userid. Based on the userid, privileges are granted.

CLI interface:

CLI interface is provided for each service. Nova services are accessible through “nova” client, Swift services are accessible with “swift” client and so on. Following example lists running VMs.

$ nova list
| ID                                   | Name                                            | Status | Task State | Power State | Networks         |
| 2dc7c43f-f7c5-4577-b286-7db2a22b57be | cirrostest-2dc7c43f-f7c5-4577-b286-7db2a22b57be | ACTIVE | -          | Running     | private= |
| 554d8453-cd74-4223-ada6-f330ac8ed345 | cirrostest-554d8453-cd74-4223-ada6-f330ac8ed345 | ACTIVE | -          | Running     | private= |

To install and use CLI interface, there are 2 options:

Local devstack machine:
Source openrc file.

cd devstack; source openrc admin demo

From remote machine:
Download the appropriate client.

sudo pip install python-novaclient
sudo pip install python-neutronclient

Download the openrc file from the machine where openstack is running(can be done from access and security tab) and export to the machine where we need to access openstack clients. Source the openrc file and then we should be able to execute the cli commands.
REST interface:

To access the REST interface, authentication token needs to be obtained. The command below gives the authentication token and list of endpoints. If we are executing on the remote machine, we need to replace the localhost with the machine ip address.

curl -d '{"auth":{"passwordCredentials":{"username": "admin", "password": "openstack"},"tenantName": "demo"}}' -H "Content-Type: application/json" http://localhost:5000/v2.0/tokens | python -m json.tool

Following output is relevant where we can get the tokenid and tenantid.The authentication token will expire at the time mentioned and after that we need to get a new token.

"token": {
            "audit_ids": [
            "expires": "2015-02-18T12:07:13Z",
            "id": "ae767b7f8cd143b29039fce7737606b3", -> authentication token
            "issued_at": "2015-02-18T11:07:13.478911",
            "tenant": {
                "description": null,
                "enabled": true,
                "id": "10f9e3f2d79740af88530902c4f2a039", -> tenant id
                "name": "demo"

Using the tenantid and authentication key, lets get the list of flavors.

$ curl http://localhost:8774/v2/10f9e3f2d79740af88530902c4f2a039/flavors -H 'X-Auth-Token: ae767b7f8cd143b29039fce7737606b3' | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1920  100  1920    0     0  10471      0 --:--:-- --:--:-- --:--:-- 10491
    "flavors": [
            "id": "1",
            "links": [
                    "href": "http://localhost:8774/v2/10f9e3f2d79740af88530902c4f2a039/flavors/1",
                    "rel": "self"
                    "href": "http://localhost:8774/10f9e3f2d79740af88530902c4f2a039/flavors/1",
                    "rel": "bookmark"
            "name": "m1.tiny"

Lets get list of servers:

$ curl http://localhost:8774/v2/10f9e3f2d79740af88530902c4f2a039/servers -H 'X-Auth-Token: ae767b7f8cd143b29039fce7737606b3' | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   775  100   775    0     0   3596      0 --:--:-- --:--:-- --:--:--  3604
    "servers": [
            "id": "2dc7c43f-f7c5-4577-b286-7db2a22b57be",
            "links": [
                    "href": "http://localhost:8774/v2/10f9e3f2d79740af88530902c4f2a039/servers/2dc7c43f-f7c5-4577-b286-7db2a22b57be",
                    "rel": "self"
                    "href": "http://localhost:8774/10f9e3f2d79740af88530902c4f2a039/servers/2dc7c43f-f7c5-4577-b286-7db2a22b57be",
                    "rel": "bookmark"
            "name": "cirrostest-2dc7c43f-f7c5-4577-b286-7db2a22b57be"
            "id": "554d8453-cd74-4223-ada6-f330ac8ed345",
            "links": [
                    "href": "http://localhost:8774/v2/10f9e3f2d79740af88530902c4f2a039/servers/554d8453-cd74-4223-ada6-f330ac8ed345",
                    "rel": "self"
                    "href": "http://localhost:8774/10f9e3f2d79740af88530902c4f2a039/servers/554d8453-cd74-4223-ada6-f330ac8ed345",
                    "rel": "bookmark"
            "name": "cirrostest-554d8453-cd74-4223-ada6-f330ac8ed345"

Postman client:

REST interface can be accessed through Postman client. Postman client for Chrome browsers can be downloaded from here. We need the tenantid and authentication token obtained in the previous step. To get list of servers, do:

auth token

For this case:

URL: http://localhost:8774/v2/10f9e3f2d79740af88530902c4f2a039/servers
GET request
X-Auth-Token, ae767b7f8cd143b29039fce7737606b3

Results will be seen in the body section.

Programmatic interface:

Openstack provides programmatic interface using Python SDK. This makes it easier to do automation. The libraries are common between the CLI and SDK. The packages installed for the CLI client is enough for the SDK. Following is a simple program to get list of flavors and servers.

from os import environ as env
from novaclient.client import Client

def get_nova_credentials_v2():
	d = {}
	d['version'] = '2'
	d['username'] = env['OS_USERNAME']
	d['api_key'] = env['OS_PASSWORD']
	d['auth_url'] = env['OS_AUTH_URL']
	d['project_id'] = env['OS_TENANT_NAME']
	return d

credentials = get_nova_credentials_v2()
nova_client = Client(**credentials)
print "--- Servers ---"
print "--- Flavors ---"

Lets run this program.

$ python 
--- Servers ---
[, ]
--- Flavors ---
[, , , , , , , ]



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s