Exemple #1
0
 def __init__(self, backupStorage):
     storage_config = self.cover_to_config(backupStorage.get('credentials'))
     try:
         if 'S3' == backupStorage['type']:
             self.client = jms_storage.S3Storage(storage_config)
         if 'OSS' == backupStorage['type']:
             self.client = jms_storage.OSSStorage(storage_config)
         if 'AZURE' == backupStorage['type']:
             self.client = jms_storage.AzureStorage(storage_config)
     except ValueError:
         pass
 def __init__(self,backupStorage):
     if isinstance(backupStorage,BackupStorage):
         backupStorage=backupStorage.get_dict()
     storage_config = self.cover_to_config(backupStorage['credentials'])
     try:
         if 'S3' == backupStorage['type']:
             self.client = jms_storage.S3Storage(storage_config)
         if 'OSS' == backupStorage['type']:
             self.client = jms_storage.OSSStorage(storage_config)
         if 'AZURE' == backupStorage['type']:
             self.client = jms_storage.AzureStorage(storage_config)
     except ValueError:
         pass
 def check_valid(self, backupStorage):
     storage_config = self.coverToConfig(self, backupStorage['credentials'])
     client = {}
     if 'S3' == backupStorage['type']:
         client = jms_storage.S3Storage(storage_config)
     if 'OSS' == backupStorage['type']:
         client = jms_storage.OSSStorage(storage_config)
     if 'AZURE' == backupStorage['type']:
         client = jms_storage.AzureStorage(storage_config)
     if client is not None:
         # 上传文件测试可用性
         file_locale_path = os.path.abspath(
             os.path.join(os.getcwd(), os.path.pardir, 'README.md'))
         return client.is_valid(file_locale_path, 'kube-operator-test')
class TestAli(TestStorageFunc):
    client = jms_storage.OSSStorage(config.ali_config)

    def test_type(self):
        self.assertEqual(self.client.type(), 'oss')