Beispiel #1
0
    def getPhysicalPlacement(self,
                             bucketName,
                             fileNameList,
                             fullDetails=False):
        '''
        Returns where in the Spectra S3 system each file in `fileNameList` is located.
        '''
        response = POINTER(libds3.LibDs3GetPhysicalPlacementResponse)()
        bulkObjs = libds3.toDs3BulkObjectList(fileNameList)
        bucketName = typeCheckString(bucketName)
        if fullDetails:
            request = libds3.lib.ds3_init_get_physical_placement(
                bucketName, bulkObjs)
        else:
            request = libds3.lib.ds3_init_get_physical_placement_full_details(
                bucketName, bulkObjs)
        error = libds3.lib.ds3_get_physical_placement(self._client, request,
                                                      byref(response))
        libds3.lib.ds3_free_request(request)

        if error:
            raise Ds3Error(error)

        placements = []
        if response:
            placements = arrayToList(response.contents.tapes,
                                     response.contents.num_tapes,
                                     lambda obj: obj.barcode.contents.value)
            libds3.lib.ds3_free_get_physical_placement_response(response)

        return placements
Beispiel #2
0
 def deleteObjects(self, bucketName, fileNameList):
     """Deletes multiple objects from the bucket using a single API call.
     """
     bulkObjs = libds3.toDs3BulkObjectList(typeCheckObjectList(fileNameList))
     request = libds3.lib.ds3_init_delete_objects(typeCheckString(bucketName))
     error = libds3.lib.ds3_delete_objects(self._client, request, bulkObjs)
     libds3.lib.ds3_free_request(request)
     if error:
         raise Ds3Error(error)
Beispiel #3
0
 def deleteObjects(self, bucketName, fileNameList):
     '''
     Deletes multiple objects from the bucket using a single API call.
     '''
     bulkObjs = libds3.toDs3BulkObjectList(fileNameList)
     request = libds3.lib.ds3_init_delete_objects(
         typeCheckString(bucketName))
     error = libds3.lib.ds3_delete_objects(self._client, request, bulkObjs)
     libds3.lib.ds3_free_request(request)
     if error:
         raise Ds3Error(error)
Beispiel #4
0
    def putBulk(self, bucketName, fileInfoList):
        """Initiates a start bulk put with the remote Spectra S3 endpoint.  The `fileInfoList` is a list of (objectName, size) tuples.
        `objectName` does not have to be the actual name on the local file system, but it will be the name that you must
        initiate a single object put to later.  `size` must reflect the actual size of the file that is being put.
        """
        bulkObjs = libds3.toDs3BulkObjectList(typeCheckObjectList(fileInfoList))
        response = POINTER(libds3.LibDs3BulkResponse)()
        request = libds3.lib.ds3_init_put_bulk(typeCheckString(bucketName), bulkObjs)
        error = libds3.lib.ds3_bulk(self._client, request, byref(response))
        libds3.lib.ds3_free_request(request)
        if error:
            raise Ds3Error(error)

        bulkResponse = Ds3BulkPlan(response)

        libds3.lib.ds3_free_bulk_response(response)

        return bulkResponse
Beispiel #5
0
    def getBulk(self, bucketName, fileNameList, chunkOrdering = True):
        """Initiates a start bulk get with the remote Spectra S3 endpoint.  All the files that will be retrieved must be specified in
        `fileNameList`.
        """
        bulkObjs = libds3.toDs3BulkObjectList(typeCheckObjectList(fileNameList))
        response = POINTER(libds3.LibDs3BulkResponse)()
        chunkOrderingValue = libds3.LibDs3ChunkOrdering.IN_ORDER
        if not chunkOrdering:
            chunkOrderingValue = libds3.LibDs3ChunkOrdering.NONE
        request = libds3.lib.ds3_init_get_bulk(typeCheckString(bucketName), bulkObjs, chunkOrderingValue)
        error = libds3.lib.ds3_bulk(self._client, request, byref(response))
        libds3.lib.ds3_free_request(request)
        if error:
            raise Ds3Error(error)

        bulkResponse = Ds3BulkPlan(response)

        libds3.lib.ds3_free_bulk_response(response)

        return bulkResponse
Beispiel #6
0
    def getBulk(self, bucketName, fileNameList, chunkOrdering=True):
        '''
        Initiates a start bulk get with the remote Spectra S3 endpoint.  All the files that will be retrieved must be specified in
        `fileNameList`.
        '''
        bulkObjs = libds3.toDs3BulkObjectList(fileNameList)
        response = POINTER(libds3.LibDs3BulkResponse)()
        chunkOrderingValue = libds3.LibDs3ChunkOrdering.IN_ORDER
        if not chunkOrdering:
            chunkOrderingValue = libds3.LibDs3ChunkOrdering.NONE
        request = libds3.lib.ds3_init_get_bulk(typeCheckString(bucketName),
                                               bulkObjs, chunkOrderingValue)
        error = libds3.lib.ds3_bulk(self._client, request, byref(response))
        libds3.lib.ds3_free_request(request)
        if error:
            raise Ds3Error(error)

        bulkResponse = Ds3BulkPlan(response)

        libds3.lib.ds3_free_bulk_response(response)

        return bulkResponse
Beispiel #7
0
    def getPhysicalPlacement(self, bucketName, fileNameList, fullDetails = False):
        """Returns where in the Spectra S3 system each file in `fileNameList` is located.
        """
        response = POINTER(libds3.LibDs3GetPhysicalPlacementResponse)()
        bulkObjs = libds3.toDs3BulkObjectList(typeCheckObjectList(fileNameList))
        bucketName=typeCheckString(bucketName)
        if fullDetails:
            request = libds3.lib.ds3_init_get_physical_placement(bucketName, bulkObjs)
        else:
            request = libds3.lib.ds3_init_get_physical_placement_full_details(bucketName, bulkObjs)
        error = libds3.lib.ds3_get_physical_placement(self._client, request, byref(response))
        libds3.lib.ds3_free_request(request)

        if error:
            raise Ds3Error(error)

        placements = []
        if response:
            placements = arrayToList(response.contents.tapes, response.contents.num_tapes, lambda obj: obj.barcode.contents.value)
            libds3.lib.ds3_free_get_physical_placement_response(response)

        return placements