'Retrieve quotas for a project.
Given a list of resources, retrieve the quotas for the given
project.
:param context: The request context, for access checks.
:param resources: A dictionary of the registered resources.
:param project_id: The ID of the project to return quotas for.
:param quota_class: If project_id != context.project_id, the
quota class cannot be determined.  This
parameter allows it to be specified.  It
will be ignored if project_id ==
context.project_id.
:param defaults: If True, the quota class value (or the
default value, if there is no value from the
quota class) will be reported if there is no
specific value for the resource.
:param usages: If True, the current in_use, reserved and allocated
counts will also be returned.'

def get_project_quotas(self, context, resources, project_id, quota_class=None, defaults=True, usages=True):

    quotas = {}
    project_quotas = db.quota_get_all_by_project(context, project_id)
    allocated_quotas = None
    default_quotas = None
    if usages:
        project_usages = db.quota_usage_get_all_by_project(context, project_id)
        allocated_quotas = db.quota_allocated_get_all_by_project(context, project_id)
        allocated_quotas.pop('project_id')
    if (project_id == context.project_id):
        quota_class = context.quota_class
    if quota_class:
        class_quotas = db.quota_class_get_all_by_name(context, quota_class)
    else:
        class_quotas = {}
    for resource in resources.values():
        if ((not defaults) and (resource.name not in project_quotas)):
            continue
        quota_val = project_quotas.get(resource.name)
        if (quota_val is None):
            quota_val = class_quotas.get(resource.name)
            if (quota_val is None):
                if (default_quotas is None):
                    default_quotas = self.get_defaults(context, resources, project_id)
                quota_val = default_quotas[resource.name]
        quotas[resource.name] = {'limit': quota_val}
        if usages:
            usage = project_usages.get(resource.name, {})
            quotas[resource.name].update(in_use=usage.get('in_use', 0), reserved=usage.get('reserved', 0))
        if allocated_quotas:
            quotas[resource.name].update(allocated=allocated_quotas.get(resource.name, 0))
    return quotas
