'Returns the current usage count for the resource.
:param context: The request context.
:param tenant_id: The ID of the tenant
:param resync_usage: Default value is set to True. Syncs
with in_use usage.'

def count_used(self, context, tenant_id, resync_usage=True):

    usage_info = quota_api.get_quota_usage_by_resource_and_tenant(context, self.name, tenant_id)
    if ((tenant_id in self._dirty_tenants) or (not usage_info) or usage_info.dirty):
        LOG.debug('Usage    tracker    for    resource:%(resource)s    and    tenant:%(tenant_id)s    is    out    of    sync,    need    to    count    used    quota', {'resource': self.name, 'tenant_id': tenant_id})
        in_use = context.session.query(self._model_class).filter_by(tenant_id=tenant_id).count()
        if resync_usage:
            usage_info = self._resync(context, tenant_id, in_use)
        else:
            resource = (usage_info.resource if usage_info else self.name)
            tenant_id = (usage_info.tenant_id if usage_info else tenant_id)
            dirty = (usage_info.dirty if usage_info else True)
            usage_info = quota_api.QuotaUsageInfo(resource, tenant_id, in_use, dirty)
        LOG.debug('Quota    usage    for    %(resource)s    was    recalculated.    Used    quota:%(used)d.', {'resource': self.name, 'used': usage_info.used})
    return usage_info.used
