Exemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(BackblazeTest, self).__init__(*args, **kwargs)
     if not (self.APPLICATION_KEY and self.ACCOUNT_ID and self.BUCKET_NAME):
         self.backblaze_test = None
     else:
         self.backblaze_test = Backblaze(self.ACCOUNT_ID,
                                         self.APPLICATION_KEY)
Exemplo n.º 2
0
def _put_meta_backblaze(storage_method, application_key):
    if not (application_key and storage_method.bucket_name != '0'
            and storage_method.account_id != '0'):
        raise exc.OioException("The client is missing backblaze parameters")
    meta = {}
    meta['backblaze.account_id'] = storage_method.account_id
    meta['backblaze.application_key'] = application_key
    meta['bucket_name'] = storage_method.bucket_name
    backblaze = Backblaze(storage_method.account_id, application_key)
    meta['authorization'] = backblaze.authorization_token
    meta['uploadToken'] = backblaze._get_upload_token_by_bucket_name(
        storage_method.bucket_name)
    return meta
Exemplo n.º 3
0
def _put_meta_backblaze(storage_method, application_key):
    if not (application_key and storage_method.bucket_name != '0' and
            storage_method.account_id != '0'):
        raise exc.OioException("The client is missing backblaze parameters")
    meta = {}
    meta['backblaze.account_id'] = storage_method.account_id
    meta['backblaze.application_key'] = application_key
    meta['bucket_name'] = storage_method.bucket_name
    backblaze = Backblaze(storage_method.account_id, application_key)
    meta['authorization'] = backblaze.authorization_token
    meta['uploadToken'] = backblaze._get_upload_token_by_bucket_name(
        storage_method.bucket_name)
    return meta
Exemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     super(BackblazeTest, self).__init__(*args, **kwargs)
     if not (self.APPLICATION_KEY and self.ACCOUNT_ID and self.BUCKET_NAME):
         self.backblaze_test = None
     else:
         self.backblaze_test = Backblaze(self.ACCOUNT_ID,
                                         self.APPLICATION_KEY)
 def collect(self):
     """
     Overrides the Collector.collect method
     """
     backblaze = Backblaze(self.account_id, self.application_key)
     # Set Metric Name
     metric_backblaze_size = "%s.%s.space" % (self.account_id,
                                              self.bucket_name)
     metric_backblaze_number = '%s.%s.number' % (self.account_id,
                                                 self.bucket_name)
     # Set Metric Value
     try:
         size, number = backblaze.get_backblaze_infos(self.bucket_name)
         self.publish(metric_backblaze_size, size)
         self.publish(metric_backblaze_number, number)
     except BackblazeException as e:
         self.log.error(e)
Exemplo n.º 6
0
 def _put_meta_backblaze(self, storage_method, application_key):
     if not (application_key and
             storage_method.bucket_name and
             storage_method.account_id):
         raise exc.ClientException("missing some backblaze parameters " +
                                   "(bucket_name=%s, account_id=%s)" %
                                   (storage_method.bucket_name,
                                    storage_method.account_id))
     meta = {}
     meta['backblaze.account_id'] = storage_method.account_id
     meta['backblaze.application_key'] = application_key
     meta['bucket_name'] = storage_method.bucket_name
     backblaze = Backblaze(storage_method.account_id, application_key)
     meta['authorization'] = backblaze.authorization_token
     meta['uploadToken'] = backblaze._get_upload_token_by_bucket_name(
         storage_method.bucket_name)
     return meta
Exemplo n.º 7
0
def _connect_put(chunk, sysmeta, backblaze_info):
    chunk_path = _get_name(chunk)
    conn = {}
    conn['chunk'] = chunk
    conn['backblaze'] = Backblaze(backblaze_info['backblaze.account_id'],
                                  backblaze_info['backblaze.application_key'],
                                  backblaze_info['authorization'],
                                  backblaze_info['uploadToken'])
    meta = sysmeta
    meta['name'] = chunk_path
    conn['sysmeta'] = meta
    return conn
Exemplo n.º 8
0
class BackblazeTest(unittest.TestCase):
    APPLICATION_KEY = None
    ACCOUNT_ID = None
    BUCKET_NAME = None

    def __init__(self, *args, **kwargs):
        super(BackblazeTest, self).__init__(*args, **kwargs)
        if not (self.APPLICATION_KEY and self.ACCOUNT_ID and self.BUCKET_NAME):
            self.backblaze_test = None
        else:
            self.backblaze_test = Backblaze(self.ACCOUNT_ID,
                                            self.APPLICATION_KEY)

    # TODO: make the test compatible with travis
    def test_backblaze(self):
        return
        self.assertTrue(self.backblaze_test is not None)
        filename = _random_word(10)
        container_id = _random_word(10)
        true_filename = _get_name(container_id, filename)
        size = self.backblaze_test.get_size(self.BUCKET_NAME)
        meta = _generate_fake_metadata(container_id, filename)
        content = _random_word(100)
        res = self.backblaze_test.upload(self.BUCKET_NAME, meta, content)
        self.assertTrue(res)
        size_after_upload = self.backblaze_test.get_size(self.BUCKET_NAME)
        self.assertTrue(size + len(content) == size_after_upload)
        res = self.backblaze_test._get_id_file_by_file_name(
            self.BUCKET_NAME, true_filename)
        self.assertTrue(res)
        res = self.backblaze_test.download(self.BUCKET_NAME, meta)
        self.assertTrue(res == content)
        res = self.backblaze_test.delete(self.BUCKET_NAME, meta)
        self.assertTrue(res)
        res = self.backblaze_test._get_id_file_by_file_name(
            self.BUCKET_NAME, true_filename)
        self.assertFalse(res)
        size_after_delete = self.backblaze_test.get_size(self.BUCKET_NAME)
        self.assertTrue(size_after_delete == size)
Exemplo n.º 9
0
class BackblazeTest(unittest.TestCase):
    APPLICATION_KEY = None
    ACCOUNT_ID = None
    BUCKET_NAME = None

    def __init__(self, *args, **kwargs):
        super(BackblazeTest, self).__init__(*args, **kwargs)
        if not (self.APPLICATION_KEY and self.ACCOUNT_ID and self.BUCKET_NAME):
            self.backblaze_test = None
        else:
            self.backblaze_test = Backblaze(self.ACCOUNT_ID,
                                            self.APPLICATION_KEY)

    # TODO: make the test compatible with travis
    def test_backblaze(self):
        return
        self.assertTrue(self.backblaze_test is not None)
        filename = _random_word(10)
        container_id = _random_word(10)
        true_filename = _get_name(container_id, filename)
        size = self.backblaze_test.get_size(self.BUCKET_NAME)
        meta = _generate_fake_metadata(container_id, filename)
        content = _random_word(100)
        res = self.backblaze_test.upload(self.BUCKET_NAME, meta, content)
        self.assertTrue(res)
        size_after_upload = self.backblaze_test.get_size(self.BUCKET_NAME)
        self.assertTrue(size + len(content) == size_after_upload)
        res = self.backblaze_test._get_id_file_by_file_name(self.BUCKET_NAME,
                                                            true_filename)
        self.assertTrue(res)
        res = self.backblaze_test.download(self.BUCKET_NAME, meta)
        self.assertTrue(res == content)
        res = self.backblaze_test.delete(self.BUCKET_NAME, meta)
        self.assertTrue(res)
        res = self.backblaze_test._get_id_file_by_file_name(self.BUCKET_NAME,
                                                            true_filename)
        self.assertFalse(res)
        size_after_delete = self.backblaze_test.get_size(self.BUCKET_NAME)
        self.assertTrue(size_after_delete == size)
Exemplo n.º 10
0
 def _get_chunk_source(self):
     return Backblaze(self.backblaze_info['backblaze.account_id'],
                      self.backblaze_info['backblaze.application_key'],
                      self.backblaze_info['authorization'])