Beispiel #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)
Beispiel #2
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
Beispiel #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
 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)
Beispiel #5
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
Beispiel #6
0
 def _get_chunk_source(self):
     return Backblaze(self.backblaze_info['backblaze.account_id'],
                      self.backblaze_info['backblaze.application_key'],
                      self.backblaze_info['authorization'])