def quota_update(context, project_id, resource, limit): with write_session() as session: quota_ref = _quota_get(context, project_id, resource, session=session) if not quota_ref: raise exception.ProjectQuotaNotFound(project_id=project_id) quota_ref.hard_limit = limit quota_ref.save(session) return quota_ref
def _quota_get(context, project_id, resource, session=None): result = model_query(context, models.Quota). \ filter_by(project_id=project_id). \ filter_by(resource=resource). \ first() if not result: raise exception.ProjectQuotaNotFound(project_id=project_id) return result
def quota_destroy_all(context, project_id): with write_session() as session: quotas = model_query(context, models.Quota). \ filter_by(project_id=project_id). \ all() if not quotas: raise exception.ProjectQuotaNotFound(project_id=project_id) for quota_ref in quotas: session.delete(quota_ref)
def quota_destroy(context, project_id, resource): with write_session() as session: quota_ref = _quota_get(context, project_id, resource, session=session) if not quota_ref: raise exception.ProjectQuotaNotFound(project_id=project_id) session.delete(quota_ref)