def show(self, req, id): context = req.environ['engine.context'] project_id = id return { 'quota_set': self._format_quota_set(id, quota.get_project_quotas(context, id)) }
def show(self, req, id): context = req.environ['engine.context'] try: db.sqlalchemy.api.authorize_project_context(context, id) return self._format_quota_set( id, quota.get_project_quotas(context, id)) except exception.NotAuthorized: raise webob.exc.HTTPForbidden()
def show(self, req, id): context = req.environ['engine.context'] try: db.sqlalchemy.api.authorize_project_context(context, id) return self._format_quota_set(id, quota.get_project_quotas(context, id)) except exception.NotAuthorized: raise webob.exc.HTTPForbidden()
def index(self, req): """ Return all global and rate limit information. """ context = req.environ['engine.context'] abs_limits = quota.get_project_quotas(context, context.project_id) rate_limits = req.environ.get("engine.limits", []) builder = self._get_view_builder(req) return builder.build(rate_limits, abs_limits)
def update(self, req, id, body): context = req.environ['engine.context'] project_id = id for key in body['quota_set'].keys(): if key in quota_resources: value = int(body['quota_set'][key]) try: db.quota_update(context, project_id, key, value) except exception.ProjectQuotaNotFound: db.quota_create(context, project_id, key, value) except exception.AdminRequired: raise webob.exc.HTTPForbidden() return {'quota_set': quota.get_project_quotas(context, project_id)}
def index(self, req): if urlparse.parse_qs(req.environ["QUERY_STRING"]).get("defaults", False): return {"quota_set_list": [self._format_quota_set("__defaults__", quota._get_default_quotas())]} else: context = req.environ["engine.context"] user = req.environ.get("user") projects = auth_manager.AuthManager().get_projects(user=user) quota_set_list = [ self._format_quota_set(project.name, quota.get_project_quotas(context, project.name)) for project in projects ] return {"quota_set_list": quota_set_list}
def update(self, req, id, body): context = req.environ['engine.context'] project_id = id resources = [ 'metadata_items', 'injected_file_content_bytes', 'volumes', 'gigabytes', 'ram', 'floating_ips', 'instances', 'injected_files', 'cores' ] for key in body['quota_set'].keys(): if key in resources: value = int(body['quota_set'][key]) try: db.quota_update(context, project_id, key, value) except exception.ProjectQuotaNotFound: db.quota_create(context, project_id, key, value) return {'quota_set': quota.get_project_quotas(context, project_id)}
def index(self, req): if urlparse.parse_qs(req.environ['QUERY_STRING']).get( 'defaults', False): return { 'quota_set_list': [ self._format_quota_set('__defaults__', quota._get_default_quotas()) ] } else: context = req.environ['engine.context'] user = req.environ.get('user') projects = auth_manager.AuthManager().get_projects(user=user) quota_set_list = [ self._format_quota_set( project.name, quota.get_project_quotas(context, project.name)) for project in projects ] return {'quota_set_list': quota_set_list}
def update(self, req, id, body): context = req.environ["engine.context"] project_id = id resources = [ "metadata_items", "injected_file_content_bytes", "volumes", "gigabytes", "ram", "floating_ips", "instances", "injected_files", "cores", ] for key in body["quota_set"].keys(): if key in resources: value = int(body["quota_set"][key]) try: db.quota_update(context, project_id, key, value) except exception.ProjectQuotaNotFound: db.quota_create(context, project_id, key, value) return {"quota_set": quota.get_project_quotas(context, project_id)}
def show(self, req, id): context = req.environ["engine.context"] project_id = id return {"quota_set": self._format_quota_set(id, quota.get_project_quotas(context, id))}