'Count a resource and return a dict.
For countable resources, invokes the count_as_dict() function and
returns its result.  Arguments following the context and
resource are passed directly to the count function declared by
the resource.
:param context: The request context, for access checks.
:param resource: The name of the resource, as a string.
:returns: A dict containing the count(s) for the resource, for example:
{\'project\': {\'instances\': 2, \'cores\': 4, \'ram\': 1024},
\'user\': {\'instances\': 1, \'cores\': 2, \'ram\': 512}}
another example:
{\'user\': {\'key_pairs\': 5}}'

def count_as_dict(self, context, resource, *args, **kwargs):

    res = self._resources.get(resource)
    if ((not res) or (not hasattr(res, 'count_as_dict'))):
        raise exception.QuotaResourceUnknown(unknown=[resource])
    return res.count_as_dict(context, *args, **kwargs)
