Ejemplo n.º 1
0
def test_update_allocation_config(resource_alloc_config):
    block_device = '/dev/test'
    with mock.patch('node_cli.core.resources.get_disk_size',
                    return_value=BIG_DISK_SIZE):
        update_resource_allocation(block_device, DEFAULT_ENV_TYPE)
        with open(RESOURCE_ALLOCATION_FILEPATH) as jfile:
            assert json.load(jfile) != INITIAL_CONFIG
Ejemplo n.º 2
0
def restore(env, backup_path):
    unpack_backup_archive(backup_path)
    failed_checks = run_host_checks(env['DISK_MOUNTPOINT'],
                                    env['ENV_TYPE'],
                                    CONTAINER_CONFIG_PATH,
                                    check_type=CheckType.PREINSTALL)
    if failed_checks:
        print_failed_requirements_checks(failed_checks)
        return False

    if env.get('SKIP_DOCKER_CONFIG') != 'True':
        configure_docker()

    link_env_file()
    configure_iptables()
    docker_lvmpy_install(env)
    init_shared_space_volume(env['ENV_TYPE'])

    update_meta(VERSION, env['CONTAINER_CONFIGS_STREAM'],
                env['DOCKER_LVMPY_STREAM'])
    update_resource_allocation(disk_device=env['DISK_MOUNTPOINT'],
                               env_type=env['ENV_TYPE'])
    compose_up(env)

    failed_checks = run_host_checks(env['DISK_MOUNTPOINT'],
                                    env['ENV_TYPE'],
                                    CONTAINER_CONFIG_PATH,
                                    check_type=CheckType.POSTINSTALL)
    if failed_checks:
        print_failed_requirements_checks(failed_checks)
        return False
    return True
Ejemplo n.º 3
0
def init(env_filepath: str, env: str) -> bool:
    sync_skale_node()

    if env.get('SKIP_DOCKER_CONFIG') != 'True':
        configure_docker()

    prepare_host(
        env_filepath,
        env['DISK_MOUNTPOINT'],
        env['SGX_SERVER_URL'],
        env_type=env['ENV_TYPE'],
    )
    link_env_file()
    download_contracts(env)
    download_filestorage_artifacts()

    configure_filebeat()
    configure_flask()
    configure_iptables()
    generate_nginx_config()

    docker_lvmpy_install(env)
    init_shared_space_volume(env['ENV_TYPE'])

    update_meta(VERSION, env['CONTAINER_CONFIGS_STREAM'],
                env['DOCKER_LVMPY_STREAM'])
    update_resource_allocation(disk_device=env['DISK_MOUNTPOINT'],
                               env_type=env['ENV_TYPE'])
    update_images(env.get('CONTAINER_CONFIGS_DIR') != '')
    compose_up(env)
    return True
Ejemplo n.º 4
0
def restore(backup_path, env_filepath):
    env = get_node_env(env_filepath)
    if env is None:
        return
    save_env_params(env_filepath)
    env['SKALE_DIR'] = SKALE_DIR
    env['BACKUP_RUN'] = 'True'  # should be str
    restored_ok = restore_op(env, backup_path)
    if not restored_ok:
        error_exit('Restore operation failed',
                   exit_code=CLIExitCodes.OPERATION_EXECUTION_ERROR)
        return
    time.sleep(RESTORE_SLEEP_TIMEOUT)
    logger.info('Generating resource allocation file ...')
    update_resource_allocation(env['DISK_MOUNTPOINT'], env['ENV_TYPE'])
    print('Node is restored from backup')
Ejemplo n.º 5
0
def init(env_filepath):
    env = get_node_env(env_filepath)
    if env is None:
        return
    inited_ok = init_op(env_filepath, env)
    if not inited_ok:
        error_exit('Init operation failed',
                   exit_code=CLIExitCodes.OPERATION_EXECUTION_ERROR)
        return
    logger.info('Waiting for containers initialization')
    time.sleep(TM_INIT_TIMEOUT)
    if not is_base_containers_alive():
        error_exit('Containers are not running',
                   exit_code=CLIExitCodes.OPERATION_EXECUTION_ERROR)
        return
    logger.info('Generating resource allocation file ...')
    update_resource_allocation(env['DISK_MOUNTPOINT'], env['ENV_TYPE'])
    logger.info('Init procedure finished')