OpenStack Common Client Library

Registered by Alexej Ababilov on 2013-05-02

Unfortunately, nova, keystone, cinder, and glance clients are very inconsistent. A lot of code was copied between all these clients instead of moving it to a common library. The code was edited without synchronization between clients, so, they have different behaviour:

* keystoneclient reissues authorization request if the token is expired but glanceclient doesn't;
* novaclient supports authorization plugins while the others don't;
* all client constructors use different parameters (api_key in nova or password in keystone and so on);
* keystoneclient authenticates immediately in __init__, while novaclient does it lazily during first method call;
* keystone- and novaclient can manage service catalogs and accept keystone's auth URI while glanceclient allows endpoints only;
* keystoneclient can support authorization with an unscoped token but novaclient doesn't;
* novaclient uses class composition while keystoneclient uses inheritance: composition allows sharing common token and service catalog between several clients.

That is worth to note that glanceclient still uses httplib instead of more convenient python-requests.

There is python-openstackclient, and it is an awesome tool. But it is a console client, not an API client library.

The basic library can be used by python-{nova,keystone,glance}client that are used, in their order, by python-openstackclient, horizon, etc.

An sample implementation of the basic library was written in Jun, 2012 and is accessible at https://github.com/aababilov/python-openstackclient-base.

Here is an example how to use the library from oslo-incubator:

from openstack.common.apiclient.client import HttpClient
http_client = HttpClient(username="...", password="...", tenant_name="...", auth_uri="...")

from novaclient.v1_1.client import Client
print Client(http_client).servers.list()

from keystoneclient.v2_0.client import Client
print Client(http_client).tenants.list()

This blueprint is a reorganization of older blueprints https://blueprints.launchpad.net/nova/+spec/basic-client-library and https://blueprints.launchpad.net/openstack-common/+spec/common-http-client

Blueprint information

Status:
Complete
Approver:
Mark McLoughlin
Priority:
Medium
Drafter:
Alexej Ababilov
Direction:
Approved
Assignee:
Alexej Ababilov
Definition:
Approved
Series goal:
Accepted for havana
Implementation:
Implemented
Milestone target:
milestone icon 2013.2
Started by
Alexej Ababilov on 2013-05-02
Completed by
Mark McLoughlin on 2013-08-13

Related branches

Sprints

Whiteboard

First part: https://review.openstack.org/27729

Second part: https://review.openstack.org/29705

Alessio - since the second patch got merged, what remains to be done before we can mark his as implemented?

Second part doesn't look merged to me --ttx

I'm pretty sure the second part relates to the common-cli-utils blueprint

Also, Adam Young appears to have some sort of issue with this: https://review.openstack.org/41578

-- markmc

The second part: (https://review.openstack.org/29705) just waits for approval. Also, I am working on moving apiclient to keystoneclient (https://review.openstack.org/#/q/status:open+project:openstack/python-keystoneclient+branch:master+topic:bp/common-client-library,n,z) - when this work will be finished, we can discuss with the keystoneclient team what part of apiclient must remain in oslo. -- alessio

(?)

Work Items

Dependency tree

* Blueprints in grey have been implemented.