コード例 #1
0
ファイル: replicas.py プロジェクト: vokac/rucio
    def get(self):
        """
        List the suspicious replicas on a list of RSEs.

        .. :quickref: SuspiciousReplicas; Get suspicious replicas.

        :resheader Content-Type: application/json
        :status 200: OK.
        :status 406: Not Acceptable.
        :returns: List of suspicious file replicas.
        """
        rse_expression, younger_than, nattempts = None, None, None
        if request.query_string:
            query_string = request.query_string.decode(encoding='utf-8')
            try:
                params = loads(unquote(query_string))
            except ValueError:
                params = parse_qs(query_string)

            if 'rse_expression' in params:
                rse_expression = params['rse_expression'][0]
            if 'younger_than' in params and params['younger_than'][0]:
                younger_than = datetime.strptime(params['younger_than'][0], "%Y-%m-%dT%H:%M:%S")
            if 'nattempts' in params:
                nattempts = int(params['nattempts'][0])

        result = get_suspicious_files(rse_expression=rse_expression, younger_than=younger_than, nattempts=nattempts, vo=request.environ.get('vo'))
        return Response(render_json_list(result), 200, content_type='application/json')
コード例 #2
0
ファイル: replica.py プロジェクト: salunkheketki19/rucio
    def get(self):
        """
        List the suspicious replicas on a list of RSEs.

        .. :quickref: SuspiciousReplicas; Get suspicious replicas.

        :resheader Content-Type: application/json
        :status 200: OK.
        :status 406: Not Acceptable.
        :status 500: Internal Error.
        :returns: List of suspicious file replicas.
        """
        result = []
        rse_expression = request.args.get('rse_expression', None)
        younger_than = request.args.get('younger_than', None)
        nattempts = request.args.get('nattempts', None)
        if younger_than:
            younger_than = datetime.strptime(younger_than,
                                             "%Y-%m-%dT%H:%M:%S.%f")

        try:
            result = get_suspicious_files(rse_expression=rse_expression,
                                          younger_than=younger_than,
                                          nattempts=nattempts)
        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 render_json_list(result)
コード例 #3
0
ファイル: didclient.py プロジェクト: pombredanne/rucio
 def add_dids(self, dids):
     """
     Bulk add datasets/containers.
     """
     path = '/'.join([self.DIDS_BASEURL])
     url = build_url(choice(self.list_hosts), path=path)
     r = self._send_request(url, type='POST', data=render_json_list(dids))
     if r.status_code == codes.created:
         return True
     else:
         exc_cls, exc_msg = self._get_exception(r.headers, r.status_code)
         raise exc_cls(exc_msg)
コード例 #4
0
ファイル: didclient.py プロジェクト: zlion/rucio
 def add_dids(self, dids):
     """
     Bulk add datasets/containers.
     """
     path = '/'.join([self.DIDS_BASEURL])
     url = build_url(choice(self.list_hosts), path=path)
     r = self._send_request(url, type='POST', data=render_json_list(dids))
     if r.status_code == codes.created:
         return True
     else:
         exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
         raise exc_cls(exc_msg)
コード例 #5
0
ファイル: didclient.py プロジェクト: pombredanne/rucio
    def attach_dids_to_dids(self, attachments):
        """
        Add dids to dids.

        :param attachments: The attachments.
            attachments is: [attachment, attachment, ...]
            attachment is: {'scope': scope, 'name': name, 'dids': dids}
            dids is: [{'scope': scope, 'name': name}, ...]
        """
        path = '/'.join([self.DIDS_BASEURL, 'attachments'])
        url = build_url(choice(self.list_hosts), path=path)
        r = self._send_request(url, type='POST', data=render_json_list(attachments))
        if r.status_code in (codes.ok, codes.no_content, codes.created):
            return True

        exc_cls, exc_msg = self._get_exception(r.headers, r.status_code)
        raise exc_cls(exc_msg)
コード例 #6
0
ファイル: replica.py プロジェクト: ijjorama/rucio
    def GET(self):
        """
        List the suspicious replicas on a lsit of RSEs.

        HTTP Success:
            200 OK

        HTTP Error:
            406 Not Acceptable
            500 InternalError

        """
        header('Content-Type', 'application/json')
        result = []
        rse_expression, younger_than, nattempts = None, None, None
        if ctx.query:
            try:
                params = loads(unquote(ctx.query[1:]))
            except ValueError:
                params = parse_qs(ctx.query[1:])
            print(params)
            if 'rse_expression' in params:
                rse_expression = params['rse_expression'][0]
            if 'younger_than' in params and params['younger_than'][0]:
                younger_than = datetime.strptime(params['younger_than'][0],
                                                 "%Y-%m-%dT%H:%M:%S")
            if 'nattempts' in params:
                nattempts = int(params['nattempts'][0])

        try:
            result = get_suspicious_files(rse_expression=rse_expression,
                                          younger_than=younger_than,
                                          nattempts=nattempts,
                                          vo=ctx.env.get('vo'))
        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)
        return render_json_list(result)