[openstack-dev] [fuel][client] new client implementation ideas

Konstantin Danilov kdanilov at mirantis.com
Wed Jan 14 09:38:44 UTC 2015


Hi all,

We are working on fuel certification script
https://github.com/stgleb/fuel-web
and have yet-one-more implementation of fuel-client, which cover very small
of Fuel API, yet we have some ideas, which you might be interesting in.

1) high-level primitives for REST operations.

    a) GET/PUT/POST/etc function, which returns closure, bonded to url and
method


        class Cluster(RestObj):
            """Class represents Cluster in Fuel"""

            add_node_call = PUT('api/nodes')
            start_deploy = PUT('api/clusters/{id}/changes')
            get_status = GET('api/clusters/{id}')
            delete = DELETE('api/clusters/{id}')

        GET(url_template) returns function/class method, which accepts set
of parameters,
        format part of them into url_template to obtain final url and pass
other parameters
        as data in http request. E.g.

        get_some_objs = GET('some/objects/{cluster_id}/really_get')


        get_some_objs(cluster_id=12, kind="db objects") will result in
        HTTP request GET '..../some/objects/12/really_get' data =
{'kind':'db objects'}

        in case of class method it also extracts missing format parameters
from self.__dict__.
        E.g.

        node = Node.get_all()[0]
        nnode = node.get() <<< takes id from node.id


    b) Auto generate API for strict restfull cases, e.g.

        class Node(RestfulObj):
            """Represents node in Fuel"""

            __url__ = '/api/nodes/{id}'

        ==

        class Node(RestObj):
            """Represents node in Fuel"""

            get_all = GET('/api/nodes')
            get = GET('/api/nodes/{id}')
            delete = DELETE('/api/nodes/{id}')
            create = POST('/api/nodes/{id}')
            ....

2) API for create cluster from yaml description. Allow to deploy whole
openstack cluster from single yaml file. We being asking a lot whenever
this call would be available in fuel client
by different team/persons.

https://github.com/stgleb/fuel-web/blob/sertification-script/certification_script/certification_script/cert_script.py#L165

3) I have a semi-implemented ideas for future-based API for background
tasks (e.g. cluster deployment)

Code is available in repo and we would be glad to help you to merge it to
new fuel-client

-- 
Kostiantyn Danilov aka koder.ua
Principal software engineer, Mirantis

skype:koder.ua
http://koder-ua.blogspot.com/
http://mirantis.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150114/1b2c6e3e/attachment.html>


More information about the OpenStack-dev mailing list