def test_transfer_s3_to_azure(self): HEADING() source_CSP = "awss3" target_CSP = "azure" source_obj = str(self.file_name) target_obj = str(Path("\\")) stopwatch_tag = "Transfer awss3 to azure" print("=======> ", source_obj) print("=======> ", target_obj) StopWatch.start(stopwatch_tag) provider = Provider(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj) result = provider.copy(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj, recursive=True) StopWatch.stop(stopwatch_tag) pprint(result) assert result is not None
def list(): setup() target_CSP = "local" target_obj = local_target provider = Provider(source=None, source_obj=None, target=target_CSP, target_obj=target_obj) result = provider.list(source=None, source_obj=None, target=target_CSP, target_obj=target_obj, recursive=True) return result
def test_local_list(self): HEADING() target_CSP = "local" target_obj = self.location StopWatch.start("List local for awss3 provider") provider = Provider(source=None, source_obj=None, target=target_CSP, target_obj=target_obj) result = provider.list(source=None, source_obj=None, target=target_CSP, target_obj=target_obj, recursive=True) StopWatch.stop("List local for awss3 provider") assert self.file_name in result[0]['name']
def test_list_s3(self): HEADING() target_CSP = "awss3" target_obj = str(Path("\\") / self.file_name) # print("===========> ", target_obj) StopWatch.start("List s3 for awss3 provider") provider = Provider(source=None, source_obj=None, target=target_CSP, target_obj=target_obj) result = provider.list(source=None, source_obj=None, target=target_CSP, target_obj=target_obj, recursive=True) StopWatch.stop("List s3 for awss3 provider") assert self.file_name in result[0]['name']
def test_delete_azure(self): HEADING() target_CSP = "azure" target_obj = str(Path("\\") / self.azure_file_name) stopwatch_tag = "Delete azure" # print("===========> ", target_obj) StopWatch.start(stopwatch_tag) provider = Provider(source=None, source_obj=None, target=target_CSP, target_obj=target_obj) result = provider.delete(source=None, source_obj=None, target=target_CSP, target_obj=target_obj, recursive=True) StopWatch.stop(stopwatch_tag) assert self.azure_file_name in result[0]['name']
def test_delete_local(self): HEADING() target_CSP = "local" target_obj = self.file_name stopwatch_tag = "Delete local" # print("===========> ", target_obj) StopWatch.start(stopwatch_tag) provider = Provider(source=None, source_obj=None, target=target_CSP, target_obj=target_obj) result = provider.delete(source=None, source_obj=None, target=target_CSP, target_obj=target_obj, recursive=True) StopWatch.stop(stopwatch_tag) assert self.file_name in result[0]['name']
def test_transfer_local_s3(self): HEADING() source_CSP = "local" target_CSP = "awss3" source_obj = str(Path(self.location)) target_obj = "\\" StopWatch.start("Transfer local to awss3") provider = Provider(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj) result = provider.copy(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj, recursive=True) StopWatch.stop("Transfer local to awss3") pprint(result) assert result is not None
def test_transfer_s3_to_local(self): HEADING() source_CSP = "awss3" target_CSP = "local" source_obj = str(Path("\\") / self.file_name) target_obj = str(Path(self.location)) StopWatch.start("Transfer awss3 to local") provider = Provider(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj) result = provider.copy(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj, recursive=True) StopWatch.stop("Transfer awss3 to local") pprint(result) assert result is not None
def test_transfer_azure_to_s3(self): HEADING() source_CSP = "azure" target_CSP = "awss3" source_obj = str(Path("\\") / self.azure_file_name) target_obj = str(Path("\\")) stopwatch_tag = "Transfer azure to local." StopWatch.start(stopwatch_tag) provider = Provider(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj) result = provider.copy(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj, recursive=False) StopWatch.stop(stopwatch_tag) pprint(result) assert result is not None
def test_transfer_local_to_azure(self): HEADING() source_CSP = "local" target_CSP = "azure" source_obj = str(Path(self.location_azure)) target_obj = "\\" stopwatch_tag = "Transfer local to azure." StopWatch.start(stopwatch_tag) provider = Provider(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj) result = provider.copy(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj, recursive=True) StopWatch.stop(stopwatch_tag) pprint(result) assert result is not None
def do_transfer(self, args, arguments): """ :: Usage: transfer copy --source=awss3:source_obj --target=azure:target_obj transfer list --target=awss3:target_obj transfer delete --target=awss3:target_obj This command is part of Cloudmesh's multi-cloud storage service. Command allows users to transfer files/directories from storage of one Cloud Service Provider (CSP) to storage of other CSP. Current implementation is to transfer data between Azure blob storage and AWS S3 bucket. AWS S3/ Azure Blob storage credentials and container details will be fetched from storage section of "~\.cloudmesh\cloudmesh.yaml" Arguments: awss3:source_obj Combination of cloud name and the source object name source_obj Source object. Can be file or a directory. azure:target_obj Combination of cloud name and the target object name target_obj Target object. Can be file or a directory. transfer_id A unique id/name assigned by cloudmesh to each transfer instance. Options: -h Help function. --source=awss3:source_obj Specify source cloud and source object. --target=azure:target_obj Specify target cloud and target object. -r Recursive transfer for folders. Description: transfer copy --source=<awss3:source_obj> . --target=<azure:target_obj> [-r] Copy file/folder from source to target. Source/target CSPs and name of the source/target objects to be provided. Optional argument "-r" indicates recursive copy. transfer list --target=awss3:target_obj Enlists available files on target CSP at target object transfer delete --target=awss3:target_obj Deletes target object from the target CSP. Examples: transfer copy --source=awss3:sampleFileS3.txt . --target=azure:sampleFileBlob.txt """ print("EXECUTING: ") map_parameters(arguments, "source", "target") VERBOSE(arguments) # Extract source and target details from the arguments if arguments.source: source_CSP, source_obj = arguments.source.split(':') else: source_CSP, source_obj = None, None if arguments.target: # print("************** ", arguments.target) target_CSP, target_obj = arguments.target.split(':') # print("************** ", target_CSP, target_obj ) else: target_CSP, target_obj = None, None banner(f'''Working on: source CSP = {source_CSP} source object = {source_obj} target CSP = {target_CSP} target object = {target_obj}''') # return if arguments.FILE: print("option a") elif arguments.list: banner(f"Executing List command for {target_CSP} provider on " f"{target_obj}.") provider = Provider(source=None, source_obj=None, target=target_CSP, target_obj=target_obj) provider.list(source=None, source_obj=None, target=target_CSP, target_obj=target_obj, recursive=True) elif arguments.delete: banner(f"Executing Delete command for {target_CSP} provider on " f"{target_obj}") provider = Provider(source=None, source_obj=None, target=target_CSP, target_obj=target_obj) provider.delete(source=None, source_obj=None, target=target_CSP, target_obj=target_obj, recursive=True) elif arguments.copy: # This flow is designed in such a way that copy command is run # in target CSP's provider banner(f"Executing Copy command from {source_CSP} to {target_CSP} " f"providers for {source_obj}") provider = Provider(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj) provider.copy(source=source_CSP, source_obj=source_obj, target=target_CSP, target_obj=target_obj, recursive=True) else: Console.error("Invalid argument provided.") return ""