Esempio n. 1
0
    def post(self, source, destination):
        """ Create distance information between source RSE and destination RSE.

        .. :quickref: Distance; Create RSE distance.

        :param source: The source RSE name.
        :param destination: The destination RSE name.
        :status 201: Created.
        :status 400: Cannot decode json parameter dictionary.
        :status 401: Invalid Auth Token.
        :status 404: RSE Not Found.
        :status 500: Internal Error.

        """
        json_data = request.data
        try:
            parameter = loads(json_data)
        except ValueError:
            return generate_http_error_flask(
                400, 'ValueError', 'Cannot decode json parameter dictionary')
        try:
            add_distance(source=source,
                         destination=destination,
                         issuer=request.environ.get('issuer'),
                         **parameter)
        except AccessDenied, error:
            return generate_http_error_flask(401, 'AccessDenied',
                                             error.args[0])
Esempio n. 2
0
    def setUpClass(cls):
        if config_get_bool('common', 'multi_vo', raise_exception=False, default=False):
            cls.vo = {'vo': config_get('client', 'vo', raise_exception=False, default='tst')}
            cls.new_vo = {'vo': 'new'}
            cls.multi_vo = True
            if not vo_exists(**cls.new_vo):
                add_vo(description='Test', email='*****@*****.**', **cls.new_vo)
        else:
            cls.vo = {}
            cls.new_vo = {}
            cls.multi_vo = False

        # Add test account
        cls.account_name = ''.join(random.choice(string.ascii_lowercase) for x in range(10))
        add_account(account=cls.account_name, type='user', email='*****@*****.**', issuer='root', **cls.vo)
        cls.account = InternalAccount(cls.account_name, **cls.vo)

        # Add test scope
        cls.scope_name = ''.join(random.choice(string.ascii_lowercase) for x in range(10))
        add_scope(scope=cls.scope_name, account=cls.account_name, issuer='root', **cls.vo)
        cls.scope = InternalScope(cls.scope_name, **cls.vo)

        # Get test RSEs
        cls.rse_name = 'MOCK'
        cls.rse_id = get_rse_id(rse=cls.rse_name, **cls.vo)
        cls.rse2_name = 'MOCK2'
        cls.rse2_id = get_rse_id(rse=cls.rse2_name, **cls.vo)

        cls.rse3_name = rse_name_generator()
        cls.rse3_id = api_rse.add_rse(cls.rse3_name, 'root', **cls.new_vo)
        cls.rse4_name = rse_name_generator()
        cls.rse4_id = api_rse.add_rse(cls.rse4_name, 'root', **cls.new_vo)
        api_rse.add_distance(cls.rse3_name, cls.rse4_name, issuer='root', distance=3, **cls.new_vo)
Esempio n. 3
0
    def POST(self, source, destination):
        """ Create distance information between source RSE and destination RSE.

        HTTP Success:
            200 Updated

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

        :param rse: The RSE name.
        """
        header('Content-Type', 'application/json')
        json_data = data()
        try:
            parameter = loads(json_data)
        except ValueError:
            raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter dictionary')
        try:
            add_distance(source=source,
                         destination=destination,
                         issuer=ctx.env.get('issuer'),
                         **parameter)
        except AccessDenied, error:
            raise generate_http_error(401, 'AccessDenied', error.args[0][0])
Esempio n. 4
0
    def post(self, source, destination):
        """ Create distance information between source RSE and destination RSE.

        .. :quickref: Distance; Create RSE distance.

        :param source: The source RSE name.
        :param destination: The destination RSE name.
        :status 201: Created.
        :status 400: Cannot decode json parameter dictionary.
        :status 401: Invalid Auth Token.
        :status 404: RSE Not Found.
        """
        parameters = json_parameters()
        kwargs = {
            'ranking': None,
            'distance': None,
            'geoip_distance': None,
            'active': None,
            'submitted': None,
            'finished': None,
            'failed': None,
            'transfer_speed': None,
        }
        for keyword in kwargs.keys():
            kwargs[keyword] = param_get(parameters,
                                        keyword,
                                        default=kwargs[keyword])

        try:
            add_distance(
                source=source,
                destination=destination,
                issuer=request.environ.get('issuer'),
                vo=request.environ.get('vo'),
                **kwargs,
            )
        except AccessDenied as error:
            return generate_http_error_flask(401, error)
        except RSENotFound as error:
            return generate_http_error_flask(404, error)
        except Duplicate as error:
            return generate_http_error_flask(409, error)

        return 'Created', 201
Esempio n. 5
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!')