Esempio n. 1
0
    def delete(self, req, id):
        context = req.environ['karbor.context']
        LOG.info("Delete quotas with id: %s", id, context=context)

        if not uuidutils.is_uuid_like(id):
            msg = _("Invalid project id provided.")
            raise exc.HTTPBadRequest(explanation=msg)
        context.can(quota_policy.DELETE_POLICY)
        try:
            db.authorize_project_context(context, id)
            QUOTAS.destroy_all_by_project(context, id)
        except exception.NotAuthorized:
            raise exc.HTTPForbidden()

        LOG.info("Delete quotas successfully.", resource={'id': id})
Esempio n. 2
0
    def detail(self, req, id):
        """Return data about the given quota."""
        context = req.environ['karbor.context']
        LOG.info("Show quotas detail with id: %s", id, context=context)

        if not uuidutils.is_uuid_like(id):
            msg = _("Invalid project id provided.")
            raise exc.HTTPBadRequest(explanation=msg)
        context.can(quota_policy.GET_POLICY)
        try:
            db.authorize_project_context(context, id)
            quota = self._get_quotas(context, id, usages=True)
        except exception.NotAuthorized:
            raise exc.HTTPForbidden()

        LOG.info("Show quotas detail successfully.", resource={'id': id})
        return self._view_builder.detail_list(req, quota, id)