Skip to content

Commit 9e3e955

Browse files
committed
Fix flake and unit test errors
1 parent 56b1d07 commit 9e3e955

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

medusa/medusacli.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ def fetch_tokenmap(medusaconfig, backup_name, bucket_name, prefix):
179179

180180
@cli.command(name='list-backups')
181181
@click.option('--show-all/--no-show-all', default=False, help="List all backups in the bucket")
182-
@click.option('--bucket-name', help='Explicit bucket name to over-ride the one from config', required=False, default=None)
182+
@click.option('--bucket-name',
183+
help='Explicit bucket name to over-ride the one from config', required=False, default=None)
183184
@click.option('--prefix', help='Path prefix in multi-tenant buckets', required=False, default=None)
184185
@pass_MedusaConfig
185186
def list_backups(medusaconfig, show_all, bucket_name, prefix):
@@ -198,7 +199,8 @@ def list_backups(medusaconfig, show_all, bucket_name, prefix):
198199
multiple=True, default={})
199200
@click.option('--ignore-system-keyspaces', help='Do not download cassandra system keyspaces', required=True,
200201
is_flag=True, default=False)
201-
@click.option('--bucket-name', help='Explicit bucket name to over-ride the one from config', required=False, default=None)
202+
@click.option('--bucket-name',
203+
help='Explicit bucket name to over-ride the one from config', required=False, default=None)
202204
@click.option('--prefix', help='Path prefix in multi-tenant buckets', required=False, default=None)
203205
@pass_MedusaConfig
204206
def download(medusaconfig, backup_name, download_destination, keyspaces, tables, ignore_system_keyspaces, bucket_name,
@@ -231,7 +233,8 @@ def download(medusaconfig, backup_name, download_destination, keyspaces, tables,
231233
@click.option('--version-target', help='Target Cassandra version', required=False, default="3.11.9")
232234
@click.option('--ignore-racks', help='Disable matching nodes based on rack topology', required=False, default=False,
233235
is_flag=True)
234-
@click.option('--bucket-name', help='Explicit bucket name to over-ride the one from config', required=False, default=None)
236+
@click.option('--bucket-name',
237+
help='Explicit bucket name to over-ride the one from config', required=False, default=None)
235238
@click.option('--prefix', help='Path prefix in multi-tenant buckets', required=False, default=None)
236239
@pass_MedusaConfig
237240
def restore_cluster(medusaconfig, backup_name, seed_target, temp_dir, host_list, keep_auth, bypass_checks,
@@ -276,7 +279,8 @@ def restore_cluster(medusaconfig, backup_name, seed_target, temp_dir, host_list,
276279
@click.option('--use-sstableloader', help='Use the sstableloader to load the backup into the cluster',
277280
default=False, is_flag=True)
278281
@click.option('--version-target', help='Target Cassandra version', required=False, default="3.11.9")
279-
@click.option('--bucket-name', help='Explicit bucket name to over-ride the one from config', required=False, default=None)
282+
@click.option('--bucket-name',
283+
help='Explicit bucket name to over-ride the one from config', required=False, default=None)
280284
@click.option('--prefix', help='Path prefix in multi-tenant buckets', required=False, default=None)
281285
@pass_MedusaConfig
282286
def restore_node(medusaconfig, temp_dir, backup_name, in_place, keep_auth, seeds, verify, keyspaces, tables,

medusa/storage/__init__.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,14 @@
2424

2525
import medusa.index
2626

27-
from medusa.storage.cluster_backup import ClusterBackup
28-
from medusa.storage.node_backup import NodeBackup
2927
from medusa.storage.abstract_storage import ManifestObject, AbstractBlob
3028
from medusa.storage.azure_storage import AzureStorage
3129
from medusa.storage.cluster_backup import ClusterBackup
3230
from medusa.storage.google_storage import GoogleStorage
3331
from medusa.storage.local_storage import LocalStorage
3432
from medusa.storage.node_backup import NodeBackup
35-
from medusa.storage.s3_base_storage import S3BaseStorage
36-
3733
from medusa.storage.s3_rgw import S3RGWStorage
38-
from medusa.storage.s3_storage import S3Storage
34+
from medusa.storage.s3_storage import S3BaseStorage, S3Storage
3935
from medusa.utils import evaluate_boolean
4036

4137
# pattern meant to match just the blob name, not the entire path
@@ -86,23 +82,23 @@ def __exit__(self, exc_type, exc_val, exc_tb):
8682
def _load_storage(self):
8783
logging.debug('Loading storage_provider: {}'.format(self._config.storage_provider))
8884
if self._config.storage_provider.lower() == 'google_storage':
89-
google_storage = GoogleStorage(self._config, bucket_name=self._bucket_name)
85+
google_storage = GoogleStorage(self._config)
9086
return google_storage
9187
elif self._config.storage_provider.lower() == 'azure_blobs':
92-
azure_storage = AzureStorage(self._config, bucket_name=self._bucket_name)
88+
azure_storage = AzureStorage(self._config)
9389
return azure_storage
9490
elif self._config.storage_provider.lower() == 's3_rgw':
95-
return S3RGWStorage(self._config, bucket_name=self._bucket_name)
91+
return S3RGWStorage(self._config)
9692
elif self._config.storage_provider.lower() == "s3_compatible":
97-
s3_storage = S3BaseStorage(self._config, bucket_name=self._bucket_name)
93+
s3_storage = S3BaseStorage(self._config)
9894
return s3_storage
9995
elif self._config.storage_provider.lower().startswith('s3'):
100-
s3_storage = S3Storage(self._config, bucket_name=self._bucket_name)
96+
s3_storage = S3Storage(self._config)
10197
return s3_storage
10298
elif self._config.storage_provider.lower() == 'local':
103-
return LocalStorage(self._config, bucket_name=self._bucket_name)
99+
return LocalStorage(self._config)
104100
elif self._config.storage_provider.lower() == "ibm_storage":
105-
s3_storage = S3BaseStorage(self._config, bucket_name=self._bucket_name)
101+
s3_storage = S3BaseStorage(self._config)
106102
return s3_storage
107103

108104
raise NotImplementedError("Unsupported storage provider")

medusa/storage/local_storage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
class LocalStorage(AbstractStorage):
3232

3333
def __init__(self, config):
34+
# in Python we usually put this last, bur we need it to set the bucket_name
35+
super().__init__(config)
36+
3437
self.config = config
3538

3639
self.root_dir = Path(config.base_path) / self.bucket_name
3740
self.root_dir.mkdir(parents=True, exist_ok=True)
3841

39-
super().__init__(config)
40-
4142
def connect(self):
4243
pass
4344

0 commit comments

Comments
 (0)