コード例 #1
0
    def copy_backup(self, backup_resource: BackupResource, target_regions: List[str]):
        """Copy backup to set of regions - this is orchestration method, rather than
            logic implementation"""
        method = 'do_copy_backup'

        # call lambda recursively for each backup / region pair
        for region in target_regions:
            arguments = {
                'OriginRegion': backup_resource.region,
                'BackupId': backup_resource.backup_id,
                'Region': region
            }
            ShelveryInvoker().invoke_shelvery_operation(self, method, arguments)
コード例 #2
0
    def share_backup(self, backup_resource: BackupResource, aws_account_id: str):
        """
        Share backup with other AWS account - this is orchestration method, rather than
        logic implementation, invokes actual implementation or lambda
        """

        method = 'do_share_backup'
        arguments = {
            'Region': backup_resource.region,
            'BackupId': backup_resource.backup_id,
            'AwsAccountId': aws_account_id
        }
        ShelveryInvoker().invoke_shelvery_operation(self, method, arguments)
コード例 #3
0
        def call_recursively():
            # check if exceeded allowed number of wait iterations in lambda
            if self.lambda_wait_iteration > RuntimeConfig.get_max_lambda_wait_iterations():
                raise Exception(f"Reached maximum of {RuntimeConfig.get_max_lambda_wait_iterations()} lambda wait"
                                f"operations")

            lambda_args['lambda_wait_iteration'] = self.lambda_wait_iteration + 1
            if lambda_method is not None and lambda_args is not None:
                ShelveryInvoker().invoke_shelvery_operation(
                    engine,
                    method_name=lambda_method,
                    method_arguments=lambda_args)
            has_timed_out['value'] = True
コード例 #4
0
    def store_backup_data(self, backup_resource: BackupResource):
        """
        Top level method to save backup data to s3 bucket.
        Invokes thread / lambda to wait until backup becomes available and only then
        the metadata is written to the bucket
        :param backup_resource:
        :return:
        """
        method = 'do_store_backup_data'
        arguments = {
            'BackupId': backup_resource.backup_id,
            'BackupRegion': backup_resource.region
        }

        ShelveryInvoker().invoke_shelvery_operation(self, method, arguments)
コード例 #5
0
    def copy_backup(self, backup_resource: BackupResource,
                    target_regions: List[str]):
        """Copy backup to set of regions - this is orchestration method, rather than
            logic implementation"""
        method = 'do_copy_backup'

        # tag source backup with dr regions
        backup_resource.tags[
            f"{RuntimeConfig.get_tag_prefix()}:dr_regions"] = ','.join(
                target_regions)
        self.tag_backup_resource(backup_resource)

        # call lambda recursively for each backup / region pair
        for region in target_regions:
            arguments = {
                'OriginRegion': backup_resource.region,
                'BackupId': backup_resource.backup_id,
                'Region': region
            }
            ShelveryInvoker().invoke_shelvery_operation(
                self, method, arguments)