Add simple capabilities API

Precursor-to: BP selectable-aggregates

The per-deployment variation in API capabilities is effectively
determined by the lack of strict feature parity across storage
drivers.

Currently we require that callers either know a priori which
features are provided and which not, or else to probe the API
and handle the NotImplementedErrors.

With the advent of more complexity in the API (complex queries,
selectable aggregates etc.) it would be useful to allow a more
direct interrogation of capabilities in the current deployment.

We expose the current set of capabilities in the form of a
simple nested dictionary, e.g.:

    {
        'meters': {'pagination': True,
                   'query': {'simple': True,
                             'complex': False}},
        'resources': {'pagination': False,
                      'query': {'simple': True,
                                'metadata': True,
                                'complex': False}},
        'samples': {'pagination': True,
                    'groupby': True,
                    'query': {'simple': True,
                              'complex': True}},
        'statistics': {'pagination': True,
                       'groupby': True,
                       'query': {'simple': True,
                                 'metadata': True,
                                 'complex': False},
                       'aggregation': {'standard': True,
                                       'selectable': {
                                           'max': True,
                                           'min': True,
                                           'sum': True,
                                           'avg': True,
                                           'count': True,
                                           'stddev': True,
                                           'cardinality': True,
                                           'quartile': False}}},
        'alarms': {'query': {'simple': True,
                             'complex': True},
                   'history': {'query': {'simple': True,
                                         'complex': True}}},
        'events': {'query': {'simple': True}},
    }

which is flattened in the usual way (using a similar approach as
used for resource metadata).

Leaf nodes of the capabilities representation are boolean, with
absence being implicitly False.

Change-Id: I8de9e153d7641d5d38ca9b79bab66887257c3010
Selectable aggregation functions for statistics

Addresses: BP selectable-aggregates

Previously, the statistics API always computed and returned a
standard set of aggregate functions.

Now, individual aggregation functions can be selected and even
parameterized via syntax of form:

   /v2/meters/<meter_name>/statistics?aggregate.func=<name>&aggregate.param=<value>

For example in order to calculate the average CPU util only:

  GET /v2/meters/cpu_util/statistics?aggregate.func=avg

  HTTP/1.0 200 OK
  [{"aggregate": {"avg": 0.6858829535841072},
    "avg": 0.6858829535841072,
    "duration_start": "2014-01-30T11:13:23",
    "duration_end": "2014-01-31T16:07:13",
    "duration": 104030.0,
    "period": 0,
    "period_start": "2014-01-30T11:13:23",
    "period_end": "2014-01-31T16:07:13",
    "groupby": null,
    "unit": "%"}]

In the current patch, selectable aggregates are provided by the
sqlalchemy driver only, with support in the mongodb driver to
follow in a subsequent patch.

Change-Id: I6cc095ba5ae16dea3f6b404e72a070ab9ac49c9a
Merge "Add simple capabilities API"
Merge "Selectable aggregation functions for statistics"