Esempio n. 1
0
    def post(self):
        """
        Create file replicas at a given RSE.

        HTTP Success:
            201 Created

        HTTP Error:
            401 Unauthorized
            405 Method Not Allowed
            409 Conflict
            500 Internal Error
            503 Service Unavailable
        """
        try:
            json_data = loads(request.data)
        except (ValueError, InvalidType):
            return generate_http_error_flask(
                400, 'ValueError', 'Cannot decode json parameter list')

        try:
            add_files(lfns=json_data['lfns'],
                      issuer=request.environ.get('issuer'),
                      ignore_availability=json_data.get(
                          'ignore_availability', False))
        except InvalidPath as error:
            return generate_http_error_flask(400, 'InvalidPath', error.args[0])
        except AccessDenied as error:
            return generate_http_error_flask(401, 'AccessDenied',
                                             error.args[0])
        except RSENotFound as error:
            return generate_http_error_flask(404, 'RSENotFound', error.args[0])
        except UnsupportedOperation as error:
            return generate_http_error_flask(405, 'UnsupportedOperation',
                                             error.args[0])
        except DataIdentifierAlreadyExists as error:
            return generate_http_error_flask(409,
                                             'DataIdentifierAlreadyExists',
                                             error.args[0])
        except Duplicate as error:
            return generate_http_error_flask(409, 'Duplicate', error.args[0])
        except DatabaseException as error:
            return generate_http_error_flask(500, 'DatabaseException',
                                             error.args[0])
        except ResourceTemporaryUnavailable as error:
            return generate_http_error_flask(503,
                                             'ResourceTemporaryUnavailable',
                                             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
        return "Created", 201
Esempio n. 2
0
    def POST(self):
        """
        Create file replicas at a given RSE.

        HTTP Success:
            201 Created

        HTTP Error:
            401 Unauthorized
            405 Method Not Allowed
            409 Conflict
            500 Internal Error
            503 Service Unavailable
        """
        json_data = data()
        try:
            parameters = parse_response(json_data)
        except (ValueError, InvalidType):
            raise generate_http_error(400, 'ValueError',
                                      'Cannot decode json parameter list')

        try:
            add_files(lfns=parameters['lfns'],
                      issuer=ctx.env.get('issuer'),
                      ignore_availability=parameters.get(
                          'ignore_availability', False))
        except InvalidPath as error:
            raise generate_http_error(400, 'InvalidPath', error.args[0])
        except AccessDenied as error:
            raise generate_http_error(401, 'AccessDenied', error.args[0])
        except UnsupportedOperation as error:
            raise generate_http_error(405, 'UnsupportedOperation',
                                      error.args[0])
        except Duplicate as error:
            raise generate_http_error(409, 'Duplicate', error.args[0])
        except DataIdentifierAlreadyExists as error:
            raise generate_http_error(409, 'DataIdentifierAlreadyExists',
                                      error.args[0])
        except RSENotFound as error:
            raise generate_http_error(404, 'RSENotFound', error.args[0])
        except DatabaseException as error:
            raise generate_http_error(503, 'DatabaseException', error.args[0])
        except ResourceTemporaryUnavailable as error:
            raise generate_http_error(503, 'ResourceTemporaryUnavailable',
                                      error.args[0])
        except RucioException as error:
            print(format_exc())
            raise generate_http_error(500, error.__class__.__name__,
                                      error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error)
        raise Created()
Esempio n. 3
0
    def post(self):
        """
        Atomic method used by the RucioFileCatalog plugin in Dirac that :
        - Creates files and their replicas
        - Creates the dataset containing the files and attach the files to the dataset
        - Creates a rule on the dataset with RSE expression ANY and grouping NONE
        - Creates all the container hierarchy containing the dataset

        ..:quickref: AddFiles; Method used by the RucioFileCatalog plugin in Dirac.

        :<json list lfns: List of lfn (dictionary {'lfn': <lfn>, 'rse': <rse>, 'bytes': <bytes>, 'adler32': <adler32>, 'guid': <guid>, 'pfn': <pfn>}.
        :<json bool ignore_availability: A boolean to choose if unavailable sites need to be ignored.

        :status 201: Created.
        :status 400: Cannot decode json parameter list.
        :status 401: Invalid auth token.
        :status 404: DID not found.
        :status 405: Unsupported Operation.
        :status 409: Duplicate.
        :status 500: Internal Error.
        :status 503: Temporary error.
        """
        try:
            parameters = parse_response(request.data)
        except (ValueError, InvalidType):
            return generate_http_error_flask(400, 'ValueError', 'Cannot decode json parameter list')

        try:
            add_files(lfns=parameters['lfns'], issuer=request.environ.get('issuer'), ignore_availability=parameters.get('ignore_availability', False))
        except InvalidPath as error:
            return generate_http_error_flask(400, 'InvalidPath', error.args[0])
        except AccessDenied as error:
            return generate_http_error_flask(401, 'AccessDenied', error.args[0])
        except UnsupportedOperation as error:
            return generate_http_error_flask(405, 'UnsupportedOperation', error.args[0])
        except Duplicate as error:
            return generate_http_error_flask(409, 'Duplicate', error.args[0])
        except DataIdentifierAlreadyExists as error:
            return generate_http_error_flask(409, 'DataIdentifierAlreadyExists', error.args[0])
        except RSENotFound as error:
            return generate_http_error_flask(404, 'RSENotFound', error.args[0])
        except DatabaseException as error:
            return generate_http_error_flask(503, 'DatabaseException', error.args[0])
        except ResourceTemporaryUnavailable as error:
            return generate_http_error_flask(503, 'ResourceTemporaryUnavailable', error.args[0])
        except RucioException as error:
            logging.exception("Internal Error")
            return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            logging.exception("Internal Error")
            return str(error), 500
        return 'Created', 201
Esempio n. 4
0
    def post(self):
        """
        Atomic method used by the RucioFileCatalog plugin in Dirac that :
        - Creates files and their replicas
        - Creates the dataset containing the files and attach the files to the dataset
        - Creates a rule on the dataset with RSE expression ANY and grouping NONE
        - Creates all the container hierarchy containing the dataset

        ..:quickref: AddFiles; Method used by the RucioFileCatalog plugin in Dirac.

        :<json list lfns: List of lfn (dictionary {'lfn': <lfn>, 'rse': <rse>, 'bytes': <bytes>, 'adler32': <adler32>, 'guid': <guid>, 'pfn': <pfn>}.
        :<json bool ignore_availability: A boolean to choose if unavailable sites need to be ignored.

        :status 201: Created.
        :status 400: Cannot decode json parameter list.
        :status 401: Invalid auth token.
        :status 404: DID not found.
        :status 405: Unsupported Operation.
        :status 409: Duplicate.
        :status 503: Temporary error.
        """
        parameters = json_parameters(parse_response)
        lfns = param_get(parameters, 'lfns')
        ignore_availability = param_get(parameters, 'ignore_availability', default=False)

        try:
            add_files(lfns=lfns, issuer=request.environ.get('issuer'), ignore_availability=ignore_availability,
                      vo=request.environ.get('vo'))
        except InvalidPath as error:
            return generate_http_error_flask(400, error)
        except AccessDenied as error:
            return generate_http_error_flask(401, error)
        except UnsupportedOperation as error:
            return generate_http_error_flask(405, error)
        except (Duplicate, DataIdentifierAlreadyExists) as error:
            return generate_http_error_flask(409, error)
        except RSENotFound as error:
            return generate_http_error_flask(404, error)
        except (DatabaseException, ResourceTemporaryUnavailable) as error:
            return generate_http_error_flask(503, error)

        return 'Created', 201
Esempio n. 5
0
    def post(self):
        """
        ---
        summary: Add files
        description: |
          Atomic method used by the RucioFileCatalog plugin in Dirac that:
          - Creates files and their replicas
          - Creates the dataset containing the files and attach the files to the dataset
          - Creates a rule on the dataset with RSE expression ANY and grouping NONE
          - Creates all the container hierarchy containing the dataset
        tags:
          - Dirac
        requestBody:
          content:
            'application/json':
              schema:
                type: object
                required:
                - lfns
                properties:
                  lfns:
                    description: "List of lfn (dictionary {'lfn': <lfn>, 'rse': <rse>, 'bytes': <bytes>, 'adler32': <adler32>, 'guid': <guid>, 'pfn': <pfn>}."
                    type: array
                    items:
                      type: object
                  ignore_availability:
                    description: If the availability should be ignored.
                    type: boolean
        responses:
          201:
            description: OK
            content:
              application/json:
                schema:
                  type: string
                  enum: ["Created"]
          400:
            description: Cannot decode json parameter list.
          401:
            description: Invalid Auth Token
          404:
            description: DID not found
          405:
            description: Unsupported Operation
          409:
            description: Duplicate
          503:
            description: Temporary error.
        """
        parameters = json_parameters(parse_response)
        lfns = param_get(parameters, 'lfns')
        ignore_availability = param_get(parameters,
                                        'ignore_availability',
                                        default=False)

        try:
            add_files(lfns=lfns,
                      issuer=request.environ.get('issuer'),
                      ignore_availability=ignore_availability,
                      vo=request.environ.get('vo'))
        except InvalidPath as error:
            return generate_http_error_flask(400, error)
        except AccessDenied as error:
            return generate_http_error_flask(401, error)
        except UnsupportedOperation as error:
            return generate_http_error_flask(405, error)
        except (Duplicate, DataIdentifierAlreadyExists) as error:
            return generate_http_error_flask(409, error)
        except RSENotFound as error:
            return generate_http_error_flask(404, error)
        except (DatabaseException, ResourceTemporaryUnavailable) as error:
            return generate_http_error_flask(503, error)

        return 'Created', 201