Hi all,

Recently a need for a single driver to support multiple API versions has
arose.

Good example of this is OpenStack driver - currently we support version 1.0
of the API, but we also plan to support version 1.1. Another example is
OpenNebula driver - currently we support version 1.4 of the API, but
versions 2.0 and 3.0 are already out and some of our users would like to use
them.

Currently we have no good and undefined way to handle this, so here is my
proposal.

Each provider driver which supports multiple API versions needs to have at
least two different classes:

- base driver class - this class implements common / api version agnostic
provider functionality
- version specific class - this class inherits from the base one and
implements version specific functionality

Base class constructor method should also act as a factory method and accept
"version" argument. Based on this version argument, the method would
instantiate a correct version specific class. If no version is provided we
should probably default to the latest version (?).

This approach also works OK with our current get_driver and provider
constants functionality - we still only need 1 constant per provider

Mike Nerone has already implemented something like this in his original
OpenStack branch - https://github.com/apache/libcloud/pull/26/files#L5R107

Feedback is welcome.

Thanks,
Tomaz

Reply via email to