deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik <>
Subject Deltacloud API revamp using modular Sinatra style
Date Wed, 11 Apr 2012 12:15:32 GMT

Maybe you already know, but I started doing a small revamp of the DC code
we currently have. The idea is to make Deltacloud API done as a modular Sinatra
application[1], thus pluggable to as a Rack container to any other application.
Also this approach will allow to use Deltacloud drivers as standard Ruby libraries,
without need to run a REST server, which could be sometime limiting.

I started an revamp by extracting the Rabbit DSL (nothing to do with RabbitMQ) out
of Deltacloud API. Rabbit is a powerfull tool that helps you create REST routes and
application logic based on Sinatra framework. Rabbit is now available as regular
Ruby gem (gem install sinatra-rabbit[2]) that provides a Sinatra extension. It should be
fully compatible with the Rabbit we currently have in Deltacloud, however I made few
improvements, to keep the code more DRY. Like, with the 'new' Rabbit you don't need
to specify the :id parameters for the :show operations and also for 'actions' (action
is an alias for 'operation', with pre-set :id parameter and POST method predefined).

The extracted Rabbit is pretty successful, it has ~30 watchers on Github, few issues
and I got few emails from people that started using it.

The next big chunk of work was to fork() Deltacloud and rewrite the 'server.rb' to modular
style, that will use this Rabbit gem. I tried *very* hard to keep all drivers and other
tools we have 99% compatible, so currently all drivers are just copied over from the original
Deltacloud API source to this fork. The only modification I made to the drivers was that I
"require 'deltacloud/base_driver'", since this was unnecessary and repeated over all drivers.

There were two big challenges. The first one was to keep the DC driver 'features'. Since those
are very tied to the Sinatra app. The second one was the 'capabilities'. Those are for checking
if the current driver support the requested operations. The result looks like this[3].
With this approach you just define the lambda function that will be executed before request
and evaluated. So we can be sure that it works also when switching drivers dynamically.

I also created a small wrapper[4] and exmaple[5] to demonstrate the 'library' use case. I
did not
spent too much time on this, but so far I tested EC2 and the mock driver and they both work

Right know, I had couple minitest scenarios, that assure the API is fully backward compatible.
However there is a ton of work that needs to be done, like:

* Porting the unit-tests, cucumber and rspec tests (do we really need all those test suites?
* Porting the CIMI interface (should be easy, just wrap the CIMI server into CIMI class)
* Create minitest scenarios for the library functionality
* Merge the project with original Deltacloud API source

  -- Michal


PS: This whole revamp is just my insomnia-time side-project/POC and is not official DC. However
    help on getting things done is welcomed :-)

Michal Fojtik

View raw message