예제 #1
0
    def test_list_requests(self):
        """ REQUEST (CORE): list requests """
        models.Request(state=constants.RequestState.WAITING, source_rse_id=self.source_rse_id, dest_rse_id=self.dest_rse_id).save(session=self.db_session)
        models.Request(state=constants.RequestState.SUBMITTED, source_rse_id=self.source_rse_id2, dest_rse_id=self.dest_rse_id).save(session=self.db_session)
        models.Request(state=constants.RequestState.SUBMITTED, source_rse_id=self.source_rse_id, dest_rse_id=self.dest_rse_id2).save(session=self.db_session)
        models.Request(state=constants.RequestState.SUBMITTED, source_rse_id=self.source_rse_id, dest_rse_id=self.dest_rse_id).save(session=self.db_session)
        models.Request(state=constants.RequestState.SUBMITTED, source_rse_id=self.source_rse_id, dest_rse_id=self.dest_rse_id).save(session=self.db_session)

        requests = [request for request in list_requests([self.source_rse_id], [self.dest_rse_id], [constants.RequestState.SUBMITTED], session=self.db_session)]
        assert len(requests) == 2

        requests = [request for request in list_requests([self.source_rse_id, self.source_rse_id2], [self.dest_rse_id], [constants.RequestState.SUBMITTED], session=self.db_session)]
        assert len(requests) == 3

        requests = [request for request in list_requests([self.source_rse_id], [self.dest_rse_id], [constants.RequestState.QUEUED], session=self.db_session)]
        assert len(requests) == 0
예제 #2
0
def list_requests(src_rses, dst_rses, states, issuer, vo='def'):
    """
    List all requests in a specific state from a source RSE to a destination RSE.

    :param src_rses: source RSEs.
    :param dst_rses: destination RSEs.
    :param states: list of request states.
    :param issuer: Issuing account as a string.
    """
    src_rse_ids = [get_rse_id(rse=rse, vo=vo) for rse in src_rses]
    dst_rse_ids = [get_rse_id(rse=rse, vo=vo) for rse in dst_rses]

    kwargs = {
        'src_rse_id': src_rse_ids,
        'dst_rse_id': dst_rse_ids,
        'issuer': issuer
    }
    if not permission.has_permission(
            issuer=issuer, vo=vo, action='list_requests', kwargs=kwargs):
        raise exception.AccessDenied(
            '%(issuer)s cannot list requests from RSE %(src_rse)s to RSE %(dst_rse)s'
            % locals())

    for req in request.list_requests(src_rse_ids, dst_rse_ids, states):
        req = req.to_dict()
        yield api_update_return_dict(req)