def storage_from_dict(backup_args, max_segment_size): storage_name = backup_args['storage'] container = backup_args['container'] if storage_name == "swift": client_manager = backup_args['client_manager'] storage = swift.SwiftStorage(client_manager, container, max_segment_size) elif storage_name == "s3": storage = s3.S3Storage(backup_args['access_key'], backup_args['secret_key'], backup_args['endpoint'], container, max_segment_size) elif storage_name == "local": storage = local.LocalStorage(storage_path=container, max_segment_size=max_segment_size) elif storage_name == "ssh": if backup_args['ssh_password']: storage = ssh.SshStorage(container, backup_args['ssh_username'], backup_args['ssh_host'], int(backup_args['ssh_port']), max_segment_size=max_segment_size, remote_pwd=backup_args['ssh_password']) else: storage = ssh.SshStorage(container, backup_args['ssh_username'], backup_args['ssh_host'], int(backup_args['ssh_port']), max_segment_size=max_segment_size, ssh_key_path=backup_args['ssh_key']) elif storage_name in ["ftp", "ftps"]: args = [ container, backup_args['ftp_password'], backup_args['ftp_username'], backup_args['ftp_host'], int(backup_args['ftp_port']), max_segment_size ] if storage_name == 'ftps': args.append(backup_args['ftp_keyfile']) args.append(backup_args['ftp_certfile']) LOG.info('args=%s' % args) storage = importutils.import_object( "freezer.storage.ftp.{0}Storage".format(storage_name.capitalize()), *args) else: raise Exception("No storage found for name {0}".format( backup_args['storage'])) return storage
def storage_from_dict(backup_args, max_segment_size): storage_name = backup_args['storage'] container = backup_args['container'] if storage_name == "swift": client_manager = backup_args['client_manager'] storage = swift.SwiftStorage(client_manager, container, max_segment_size) elif storage_name == "s3": storage = s3.S3Storage(backup_args['access_key'], backup_args['secret_key'], backup_args['endpoint'], container, max_segment_size) elif storage_name == "local": storage = local.LocalStorage(storage_path=container, max_segment_size=max_segment_size) elif storage_name == "ssh": storage = ssh.SshStorage( container, backup_args['ssh_key'], backup_args['ssh_username'], backup_args['ssh_host'], int(backup_args.get('ssh_port', freezer_config.DEFAULT_SSH_PORT)), max_segment_size=max_segment_size) else: raise Exception("No storage found for name {0}".format( backup_args['storage'])) return storage