Esempio n. 1
0
def test_prepare_migration_scripts():
    configs = [
        SourceFiles('source_host1',
                    'source_dir1',
                    'target_dir1',
                    rsync_args=['--checksum'],
                    files=[],
                    exclude=[]),
        SourceFiles('source_host1',
                    'source_dir2',
                    'target_dir2',
                    files=['file3', 'file4'],
                    exclude=[]),
        SourceFiles('source_host2',
                    'source_dir1',
                    'target_dir1',
                    files=['file5', 'file6'],
                    exclude=['logs/*', 'file.conf'])
    ]
    target_host = 'target_host1'
    prepare_file_copy_scripts(target_host, configs, SCRIPT_ROOT)
    _check_file_contents(
        os.path.join(SCRIPT_ROOT, target_host, FILE_MIGRATION_RSYNC_SCRIPT),
        os.path.join(TEST_DATA_DIR, FILE_MIGRATION_RSYNC_SCRIPT))

    for config in configs[1:]:  # first config has no files list
        file_list_filename = get_file_list_filename(config)
        file_path = os.path.join(SCRIPT_ROOT, target_host, file_list_filename)
        file_list = get_file_contents(file_path).splitlines()
        assert_equal(file_list, config.files)
def test_prepare_migration_scripts():
    configs = [
        SourceFiles(
            'source_host1',
            'source_dir1',
            'target_dir1',
            rsync_args=['--checksum'],
            files=[],
            exclude=[]
        ),
        SourceFiles(
            'source_host1',
            'source_dir2',
            'target_dir2',
            files=['file3', 'file4'],
            exclude=[]
        ),
        SourceFiles(
            'source_host2',
            'source_dir1',
            'target_dir1',
            files=['file5', 'file6'],
            exclude=['logs/*', 'file.conf']
        )
    ]
    target_host = 'target_host1'
    prepare_file_copy_scripts(target_host, configs, SCRIPT_ROOT)
    _check_file_contents(
        os.path.join(SCRIPT_ROOT, target_host, FILE_MIGRATION_RSYNC_SCRIPT),
        os.path.join(TEST_DATA_DIR, FILE_MIGRATION_RSYNC_SCRIPT)
    )

    for config in configs[1:]:  # first config has no files list
        file_list_filename = get_file_list_filename(config)
        file_path = os.path.join(SCRIPT_ROOT, target_host, file_list_filename)
        file_list = get_file_contents(file_path).splitlines()
        assert_equal(file_list, config.files)
Esempio n. 3
0
def generate_rsync_lists(migration):
    migration_file_configs = get_migration_file_configs(migration)
    for target_host, files_for_node in migration_file_configs.items():
        prepare_file_copy_scripts(target_host, files_for_node,
                                  migration.rsync_files_path)
    return list(migration_file_configs)
Esempio n. 4
0
def generate_rsync_lists(migration):
    migration_file_configs = get_migration_file_configs(migration)
    for target_host, files_for_node in migration_file_configs.items():
        prepare_file_copy_scripts(target_host, files_for_node, migration.rsync_files_path)
    return list(migration_file_configs)