Esempio n. 1
0
 def test_rename(self):
     """ OBJECTSTORE (COMMON): Rename """
     url = self.url
     new_url = '%s_new' % url
     objectstore.rename(url, new_url, rse=self.rse)
     ret = objectstore.get_metadata([url], rse=self.rse)
     if not isinstance(ret[url], exception.SourceNotFound):
         raise ret[url]
     ret = objectstore.get_metadata([new_url], rse=self.rse)
     if isinstance(ret[new_url], Exception):
         raise ret[new_url]
     if 'filesize' not in ret[new_url]:
         raise Exception("Respone not as expected: should return {'filesize': filesize}, but it returns: %s" % ret[url])
Esempio n. 2
0
    def POST(self, rse):
        """
        Get files metadata at a given RSE.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            500 Internal Error
        """
        header('Content-Type', 'application/json')
        json_data = data()
        try:
            parameters = parse_response(json_data)
        except ValueError:
            raise generate_http_error(400, 'ValueError',
                                      'Cannot decode json parameter list')

        try:
            result = objectstore.get_metadata(parameters, rse=rse)
            for url in result:
                if isinstance(result[url], Exception):
                    raise result[url]
            return render_json(**result)
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__,
                                      error.args[0])
        except Exception as error:
            print(traceback.format_exc())
            raise InternalError(error)
Esempio n. 3
0
 def test_get_metadata_not_exist(self):
     """ OBJECTSTORE (COMMON): Get metadata for not exist url """
     url = '%s_not_exist' % (self.url)
     ret = objectstore.get_metadata([url], rse=self.rse)
     if isinstance(ret[url], Exception):
         raise ret[url]
     raise Exception("Respone not as expected: should catch SourceNotFound")
Esempio n. 4
0
    def post(self, rse):
        """
        Pass list of urls and return their metadata.

        .. :quickref: ObjectStoreInfo; Get files metadata at a given RSE.

        :param rse: RSE name.
        :<json string urls: A list of URL string.
        :resheader Content-Type: application/json
        :status 200: OK.
        :status 400: Cannot decode json parameter list.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        :returns: Dictonary of metadata.
        """
        json_data = request.data
        try:
            parameters = parse_response(json_data)
        except ValueError:
            return generate_http_error_flask(400, 'ValueError', 'Cannot decode json parameter list')

        try:
            result = objectstore.get_metadata(parameters, rse=rse)
            for url in result:
                if isinstance(result[url], Exception):
                    return Response(result[url])
            return Response(render_json(**result), content_type="application/json")
        except RucioException, e:
            return generate_http_error_flask(500, e.__class__.__name__, e.args[0][0])
Esempio n. 5
0
 def test_get_metadata(self):
     """ OBJECTSTORE (COMMON): Get metadata """
     url = self.url
     ret = objectstore.get_metadata([url], rse=self.rse)
     if isinstance(ret[url], Exception):
         raise ret[url]
     if 'filesize' not in ret[url]:
         raise Exception("Respone not as expected: should return {'filesize': filesize}, but it returns: %s" % ret[url])