def show(self, req, id): context = req.environ["cinder.context"] authorize_show(context) try: sqlalchemy_api.authorize_project_context(context, id) except exception.NotAuthorized: raise webob.exc.HTTPForbidden() return self._format_quota_set(id, self._get_quotas(context, id))
def show(self, req, id): context = req.environ['cinder.context'] authorize_show(context) try: sqlalchemy_api.authorize_project_context(context, id) except exception.NotAuthorized: raise webob.exc.HTTPForbidden() return self._format_quota_set(id, self._get_quotas(context, id))
def show(self, req, id): """Show quota for a particular tenant This works for hierarchical and non-hierarchical projects. For hierarchical projects admin of current project, immediate parent of the project or the CLOUD admin are able to perform a show. :param req: request :param id: target project id that needs to be updated """ context = req.environ['cinder.context'] authorize_show(context) params = req.params target_project_id = id if not hasattr(params, '__call__') and 'usage' in params: usage = strutils.bool_from_string(params['usage']) else: usage = False try: # With hierarchical projects, only the admin of the current project # or the root project has privilege to perform quota show # operations. target_project = self._get_project(context, target_project_id) context_project = self._get_project(context, context.project_id, subtree_as_ids=True) self._authorize_show(context_project, target_project) parent_project_id = target_project.parent_id except exceptions.Forbidden: # NOTE(e0ne): Keystone API v2 requires admin permissions for # project_get method. We ignore Forbidden exception for # non-admin users. parent_project_id = None try: sqlalchemy_api.authorize_project_context(context, target_project_id) except exception.NotAuthorized: raise webob.exc.HTTPForbidden() quotas = self._get_quotas(context, target_project_id, usage, parent_project_id=parent_project_id) return self._format_quota_set(target_project_id, quotas)
def show(self, req, id): context = req.environ['cinder.context'] authorize_show(context) params = req.params if not hasattr(params, '__call__') and 'usage' in params: usage = strutils.bool_from_string(params['usage']) else: usage = False try: sqlalchemy_api.authorize_project_context(context, id) except exception.NotAuthorized: raise webob.exc.HTTPForbidden() return self._format_quota_set(id, self._get_quotas(context, id, usage))
def show(self, req, id): """Show quota for a particular tenant This works for hierarchical and non-hierarchical projects. For hierarchical projects admin of current project, immediate parent of the project or the CLOUD admin are able to perform a show. :param req: request :param id: target project id that needs to be updated """ context = req.environ['cinder.context'] authorize_show(context) params = req.params target_project_id = id if not hasattr(params, '__call__') and 'usage' in params: usage = strutils.bool_from_string(params['usage']) else: usage = False try: # With hierarchical projects, only the admin of the current project # or the root project has privilege to perform quota show # operations. target_project = self._get_project(context, target_project_id) context_project = self._get_project(context, context.project_id, subtree_as_ids=True) self._authorize_show(context_project, target_project) parent_project_id = target_project.parent_id except exceptions.Forbidden: # NOTE(e0ne): Keystone API v2 requires admin permissions for # project_get method. We ignore Forbidden exception for # non-admin users. parent_project_id = target_project_id try: sqlalchemy_api.authorize_project_context(context, target_project_id) except exception.NotAuthorized: raise webob.exc.HTTPForbidden() quotas = self._get_quotas(context, target_project_id, usage, parent_project_id=parent_project_id) return self._format_quota_set(target_project_id, quotas)
def show(self, req, id): """Show quota for a particular tenant This works for hierarchical and non-hierarchical projects. For hierarchical projects admin of current project, immediate parent of the project or the CLOUD admin are able to perform a show. :param req: request :param id: target project id that needs to be shown """ context = req.environ['cinder.context'] authorize_show(context) params = req.params target_project_id = id if not hasattr(params, '__call__') and 'usage' in params: usage = strutils.bool_from_string(params['usage']) else: usage = False if QUOTAS.using_nested_quotas(): # With hierarchical projects, only the admin of the current project # or the root project has privilege to perform quota show # operations. target_project = quota_utils.get_project_hierarchy( context, target_project_id) context_project = quota_utils.get_project_hierarchy( context, context.project_id, subtree_as_ids=True, is_admin_project=context.is_admin) self._authorize_show(context_project, target_project) try: sqlalchemy_api.authorize_project_context(context, target_project_id) except exception.NotAuthorized: raise webob.exc.HTTPForbidden() quotas = self._get_quotas(context, target_project_id, usage) return self._format_quota_set(target_project_id, quotas)
def show(self, req, id): """Show quota for a particular tenant This works for hierarchical and non-hierarchical projects. For hierarchical projects admin of current project, immediate parent of the project or the CLOUD admin are able to perform a show. :param req: request :param id: target project id that needs to be shown """ context = req.environ['cinder.context'] authorize_show(context) params = req.params target_project_id = id if not hasattr(params, '__call__') and 'usage' in params: usage = utils.get_bool_param('usage', params) else: usage = False if QUOTAS.using_nested_quotas(): # With hierarchical projects, only the admin of the current project # or the root project has privilege to perform quota show # operations. target_project = quota_utils.get_project_hierarchy( context, target_project_id) context_project = quota_utils.get_project_hierarchy( context, context.project_id, subtree_as_ids=True, is_admin_project=context.is_admin) self._authorize_show(context_project, target_project) try: sqlalchemy_api.authorize_project_context(context, target_project_id) except exception.NotAuthorized: raise webob.exc.HTTPForbidden() quotas = self._get_quotas(context, target_project_id, usage) return self._format_quota_set(target_project_id, quotas)