Skip to content

Commit

Permalink
Fix flake and unit test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvoncek committed Apr 23, 2024
1 parent 56b1d07 commit 9e3e955
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
12 changes: 8 additions & 4 deletions medusa/medusacli.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def fetch_tokenmap(medusaconfig, backup_name, bucket_name, prefix):

@cli.command(name='list-backups')
@click.option('--show-all/--no-show-all', default=False, help="List all backups in the bucket")
@click.option('--bucket-name', help='Explicit bucket name to over-ride the one from config', required=False, default=None)
@click.option('--bucket-name',
help='Explicit bucket name to over-ride the one from config', required=False, default=None)
@click.option('--prefix', help='Path prefix in multi-tenant buckets', required=False, default=None)
@pass_MedusaConfig
def list_backups(medusaconfig, show_all, bucket_name, prefix):
Expand All @@ -198,7 +199,8 @@ def list_backups(medusaconfig, show_all, bucket_name, prefix):
multiple=True, default={})
@click.option('--ignore-system-keyspaces', help='Do not download cassandra system keyspaces', required=True,
is_flag=True, default=False)
@click.option('--bucket-name', help='Explicit bucket name to over-ride the one from config', required=False, default=None)
@click.option('--bucket-name',
help='Explicit bucket name to over-ride the one from config', required=False, default=None)
@click.option('--prefix', help='Path prefix in multi-tenant buckets', required=False, default=None)
@pass_MedusaConfig
def download(medusaconfig, backup_name, download_destination, keyspaces, tables, ignore_system_keyspaces, bucket_name,
Expand Down Expand Up @@ -231,7 +233,8 @@ def download(medusaconfig, backup_name, download_destination, keyspaces, tables,
@click.option('--version-target', help='Target Cassandra version', required=False, default="3.11.9")
@click.option('--ignore-racks', help='Disable matching nodes based on rack topology', required=False, default=False,
is_flag=True)
@click.option('--bucket-name', help='Explicit bucket name to over-ride the one from config', required=False, default=None)
@click.option('--bucket-name',
help='Explicit bucket name to over-ride the one from config', required=False, default=None)
@click.option('--prefix', help='Path prefix in multi-tenant buckets', required=False, default=None)
@pass_MedusaConfig
def restore_cluster(medusaconfig, backup_name, seed_target, temp_dir, host_list, keep_auth, bypass_checks,
Expand Down Expand Up @@ -276,7 +279,8 @@ def restore_cluster(medusaconfig, backup_name, seed_target, temp_dir, host_list,
@click.option('--use-sstableloader', help='Use the sstableloader to load the backup into the cluster',
default=False, is_flag=True)
@click.option('--version-target', help='Target Cassandra version', required=False, default="3.11.9")
@click.option('--bucket-name', help='Explicit bucket name to over-ride the one from config', required=False, default=None)
@click.option('--bucket-name',
help='Explicit bucket name to over-ride the one from config', required=False, default=None)
@click.option('--prefix', help='Path prefix in multi-tenant buckets', required=False, default=None)
@pass_MedusaConfig
def restore_node(medusaconfig, temp_dir, backup_name, in_place, keep_auth, seeds, verify, keyspaces, tables,
Expand Down
20 changes: 8 additions & 12 deletions medusa/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@

import medusa.index

from medusa.storage.cluster_backup import ClusterBackup
from medusa.storage.node_backup import NodeBackup
from medusa.storage.abstract_storage import ManifestObject, AbstractBlob
from medusa.storage.azure_storage import AzureStorage
from medusa.storage.cluster_backup import ClusterBackup
from medusa.storage.google_storage import GoogleStorage
from medusa.storage.local_storage import LocalStorage
from medusa.storage.node_backup import NodeBackup
from medusa.storage.s3_base_storage import S3BaseStorage

from medusa.storage.s3_rgw import S3RGWStorage
from medusa.storage.s3_storage import S3Storage
from medusa.storage.s3_storage import S3BaseStorage, S3Storage
from medusa.utils import evaluate_boolean

# pattern meant to match just the blob name, not the entire path
Expand Down Expand Up @@ -86,23 +82,23 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def _load_storage(self):
logging.debug('Loading storage_provider: {}'.format(self._config.storage_provider))
if self._config.storage_provider.lower() == 'google_storage':
google_storage = GoogleStorage(self._config, bucket_name=self._bucket_name)
google_storage = GoogleStorage(self._config)
return google_storage
elif self._config.storage_provider.lower() == 'azure_blobs':
azure_storage = AzureStorage(self._config, bucket_name=self._bucket_name)
azure_storage = AzureStorage(self._config)
return azure_storage
elif self._config.storage_provider.lower() == 's3_rgw':
return S3RGWStorage(self._config, bucket_name=self._bucket_name)
return S3RGWStorage(self._config)
elif self._config.storage_provider.lower() == "s3_compatible":
s3_storage = S3BaseStorage(self._config, bucket_name=self._bucket_name)
s3_storage = S3BaseStorage(self._config)
return s3_storage
elif self._config.storage_provider.lower().startswith('s3'):
s3_storage = S3Storage(self._config, bucket_name=self._bucket_name)
s3_storage = S3Storage(self._config)
return s3_storage
elif self._config.storage_provider.lower() == 'local':
return LocalStorage(self._config, bucket_name=self._bucket_name)
return LocalStorage(self._config)
elif self._config.storage_provider.lower() == "ibm_storage":
s3_storage = S3BaseStorage(self._config, bucket_name=self._bucket_name)
s3_storage = S3BaseStorage(self._config)
return s3_storage

raise NotImplementedError("Unsupported storage provider")
Expand Down
5 changes: 3 additions & 2 deletions medusa/storage/local_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
class LocalStorage(AbstractStorage):

def __init__(self, config):
# in Python we usually put this last, bur we need it to set the bucket_name
super().__init__(config)

self.config = config

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

super().__init__(config)

def connect(self):
pass

Expand Down

0 comments on commit 9e3e955

Please sign in to comment.