예제 #1
0
    def POST(self, account, rse):
        """ Create or update an account limit.
        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            404 Not Found
            500 Internal Error

        :param X-Rucio-Auth-Account: Account identifier.
        :param X-Rucio-Auth-Token:   As an 32 character hex string.
        :param account:              Account name.
        :param rse:                  RSE name.
        """
        json_data = data()
        try:
            parameter = loads(json_data)
        except ValueError:
            raise generate_http_error(
                400, 'ValueError', 'cannot decode json parameter dictionary')
        try:
            bytes = parameter['bytes']
        except KeyError as exception:
            if exception.args[0] == 'type':
                raise generate_http_error(400, 'KeyError',
                                          '%s not defined' % str(exception))
        except TypeError:
            raise generate_http_error(400, 'TypeError',
                                      'body must be a json dictionary')

        try:
            set_account_limit(account=account,
                              rse=rse,
                              bytes=bytes,
                              issuer=ctx.env.get('issuer'))
        except AccessDenied as exception:
            raise generate_http_error(401, 'AccessDenied',
                                      exception.args[0][0])
        except RSENotFound as exception:
            raise generate_http_error(404, 'RSENotFound', exception.args[0][0])
        except AccountNotFound as exception:
            raise generate_http_error(404, 'AccountNotFound',
                                      exception.args[0][0])
        except Exception as exception:
            print format_exc()
            raise InternalError(exception)

        raise Created()
예제 #2
0
    def post(self, account, rse):
        """ Create or update an account limit.

        .. :quickref: AccountLimit; Create/update account limits.

        :param account: Account name.
        :param rse: RSE name.
        :status 201: Successfully created or updated.
        :status 401: Invalid auth token.
        :status 404: RSE not found.
        :status 404: Account not found
        """
        json_data = request.data
        try:
            parameter = loads(json_data)
        except ValueError:
            return generate_http_error_flask(
                400, 'ValueError', 'cannot decode json parameter dictionary')
        try:
            bytes = parameter['bytes']
        except KeyError as exception:
            if exception.args[0] == 'type':
                return generate_http_error_flask(
                    400, 'KeyError', '%s not defined' % str(exception))
        except TypeError:
            return generate_http_error_flask(400, 'TypeError',
                                             'body must be a json dictionary')

        try:
            set_account_limit(account=account,
                              rse=rse,
                              bytes=bytes,
                              issuer=request.environ.get('issuer'))
        except AccessDenied as exception:
            return generate_http_error_flask(401, 'AccessDenied',
                                             exception.args[0])
        except RSENotFound as exception:
            return generate_http_error_flask(404, 'RSENotFound',
                                             exception.args[0])
        except AccountNotFound as exception:
            return generate_http_error_flask(404, 'AccountNotFound',
                                             exception.args[0])
        except Exception as exception:
            print(format_exc())
            return exception, 500

        return "Created", 201
예제 #3
0
    # Setting up RSE attributes
    print('    Setting attributes...')
    add_rse_attribute(CNAF_STORM_id, key='istape', value='False')
    add_rse_attribute(CNAF_STORM_id,
                      key='supported_checksums',
                      value='adler32')

    # Setup fts connection
    print('    Setting FTS server...')
    add_rse_attribute(CNAF_STORM_id,
                      key='fts',
                      value='https://fts3-pilot.cern.ch:8446')

    print('DONE!')

    #==================================================================================
    # Setting up account limits
    print('Setting account limits...')
    set_account_limit('root', 'CNAF_STORM', 100000000000, 'root')
    set_account_limit('root', 'CNAF_GRIDFTP', 100000000000, 'root')
    set_account_limit('gfronze', 'CNAF_STORM', 100000000000, 'root')
    set_account_limit('gfronze', 'CNAF_GRIDFTP', 0, 'root')

    # Setting up distances
    print('Setting distances...')
    add_distance('CNAF_STORM', 'CNAF_GRIDFTP', 'root', 1, 1)
    add_distance('CNAF_GRIDFTP', 'CNAF_STORM', 'root', 1, 1)

    print('DONE!')
예제 #4
0
    add_protocol(CCIN2P3_GRIDFTP_id, params)

    # Setting up RSE attributes
    print('    Setting attributes...')
    add_rse_attribute(CCIN2P3_GRIDFTP_id, key='istape', value='False')
    add_rse_attribute(CCIN2P3_GRIDFTP_id,
                      key='supported_checksums',
                      value='md5')

    # Setup fts connection
    print('    Setting FTS server...')
    add_rse_attribute(CCIN2P3_GRIDFTP_id,
                      key='fts',
                      value='https://fts3-pilot.cern.ch:8446')

    print('DONE!')

    #==================================================================================
    # Setting up account limits
    print('Setting account limits...')
    set_account_limit('root', 'CCIN2P3_GRIDFTP', 100000000000, 'root')
    set_account_limit('gfronze', 'CCIN2P3_GRIDFTP', 10000, 'root')

    # Setting up distances
    print('Setting distances...')
    add_distance('CCIN2P3_GRIDFTP', 'CNAF_GRIDFTP', 'root', 1, 1)
    add_distance('CNAF_GRIDFTP', 'CCIN2P3_GRIDFTP', 'root', 1, 1)
    add_distance('CCIN2P3_GRIDFTP', 'CNAF_STORM', 'root', 1, 1)
    add_distance('CNAF_STORM', 'CCIN2P3_GRIDFTP', 'root', 1, 1)

    print('DONE!')
예제 #5
0
        """
        json_data = data()
        try:
            parameter = loads(json_data)
        except ValueError:
            raise generate_http_error(400, 'ValueError', 'cannot decode json parameter dictionary')
        try:
            bytes = parameter['bytes']
        except KeyError, e:
            if e.args[0] == 'type':
                raise generate_http_error(400, 'KeyError', '%s not defined' % str(e))
        except TypeError:
                raise generate_http_error(400, 'TypeError', 'body must be a json dictionary')

        try:
            set_account_limit(account=account, rse=rse, bytes=bytes, issuer=ctx.env.get('issuer'))
        except AccessDenied, e:
            raise generate_http_error(401, 'AccessDenied', e.args[0][0])
        except RSENotFound, e:
            raise generate_http_error(404, 'RSENotFound', e.args[0][0])
        except AccountNotFound, e:
            raise generate_http_error(404, 'AccountNotFound', e.args[0][0])
        except Exception, e:
            print format_exc()
            raise InternalError(e)

        raise Created()

    def DELETE(self, account, rse):
        """ Delete an account limit.
        HTTP Success: