Exemplo n.º 1
0
    def get(self, rse):
        """
        Get account usage and limit for one RSE.

        .. :quickref: RSEAccountUsageLimit; Get account usage.

        :param rse: the RSE name.
        :resheader Content-Type: application/json
        :status 200: OK.
        :status 401: Invalid Auth Token.
        :status 404: RSE Not Found.
        :status 406: Not Acceptable.
        :status 500: Internal Error.
        :returns: Line separated list of dict with account usage and limits.

        """
        try:
            usage = get_rse_account_usage(rse=rse,
                                          vo=request.environ.get('vo'))
            data = ""
            for row in usage:
                data = dumps(row, cls=APIEncoder) + '\n'
            return Response(data, content_type="application/json")
        except RSENotFound as error:
            return generate_http_error_flask(404, 'RSENotFound', error.args[0])
        except RucioException as error:
            return generate_http_error_flask(500, error.__class__.__name__,
                                             error.args[0])
        except Exception as error:
            print(format_exc())
            return error, 500
Exemplo n.º 2
0
    def GET(self, rse):
        """
        Get account usage and limit for one RSE.

        :param rse: the RSE name.
        """
        header('Content-Type', 'application/json')
        try:
            usage = get_rse_account_usage(rse=rse)
            for row in usage:
                yield dumps(row, cls=APIEncoder) + '\n'
        except RSENotFound, error:
            raise generate_http_error(404, 'RSENotFound', error[0][0])
Exemplo n.º 3
0
    def GET(self, rse):
        """
        Get account usage and limit for one RSE.

        :param rse: the RSE name.
        """
        header('Content-Type', 'application/json')
        try:
            usage = get_rse_account_usage(rse=rse, vo=ctx.env.get('vo'))
            for row in usage:
                yield dumps(row, cls=APIEncoder) + '\n'
        except RSENotFound as error:
            raise generate_http_error(404, 'RSENotFound', error.args[0])
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error)
Exemplo n.º 4
0
    def get(self, rse):
        """
        Get account usage and limit for one RSE.

        .. :quickref: RSEAccountUsageLimit; Get account usage.

        :param rse: the RSE name.
        :resheader Content-Type: application/json
        :status 200: OK.
        :status 401: Invalid Auth Token.
        :status 404: RSE Not Found.
        :status 500: Internal Error.
        :returns: Line separated list of dict with account usage and limits.

        """
        try:
            usage = get_rse_account_usage(rse=rse)
            data = ""
            for row in usage:
                data = dumps(row, cls=APIEncoder) + '\n'
            return Response(data, content_type="application/json")
        except RSENotFound, error:
            return generate_http_error_flask(404, 'RSENotFound', error.args[0])
Exemplo n.º 5
0
 def generate(vo):
     for usage in get_rse_account_usage(rse=rse, vo=vo):
         yield render_json(**usage) + '\n'