'Initializes a CountableResource.
Countable resources are those resources which directly
correspond to objects in the database, i.e., instances, cores,
etc., but for which a count by project ID is inappropriate.  A
CountableResource must be constructed with a counting
function, which will be called to determine the current counts
of the resource.
The counting function will be passed the context, along with
the extra positional and keyword arguments that are passed to
Quota.count_as_dict().  It should return a dict specifying the
count scoped to a project and/or a user.
Example count of instances, cores, or ram returned as a rollup
of all the resources since we only want to query the instances
table once, not multiple times, for each resource.
Instances, cores, and ram are counted across a project and
across a user:
{\'project\': {\'instances\': 5, \'cores\': 8, \'ram\': 4096},
\'user\': {\'instances\': 1, \'cores\': 2, \'ram\': 512}}
Example count of server groups keeping a consistent format.
Server groups are counted across a project and across a user:
{\'project\': {\'server_groups\': 7},
\'user\': {\'server_groups\': 2}}
Example count of key pairs keeping a consistent format.
Key pairs are counted across a user only:
{\'user\': {\'key_pairs\': 5}}
Note that this counting is not performed in a transaction-safe
manner.  This resource class is a temporary measure to provide
required functionality, until a better approach to solving
this problem can be evolved.
:param name: The name of the resource, i.e., "instances".
:param count_as_dict: A callable which returns the count of the
resource as a dict.  The arguments passed are as
described above.
:param flag: The name of the flag or configuration option
which specifies the default value of the quota
for this resource.'

def __init__(self, name, count_as_dict, flag=None):

    super(CountableResource, self).__init__(name, flag=flag)
    self.count_as_dict = count_as_dict
