Beispiel #1
0
def _main__level_three(messenger, options):
    messenger.banner()

    stdout_wanted = options.verbosity is VERBOSITY_VERBOSE

    if stdout_wanted:
        child_process_stdout = None
    else:
        child_process_stdout = open('/dev/null', 'w')

    sanitize_path()

    executor = Executor(messenger, stdout=child_process_stdout)

    machine_config = MachineConfig(
        options.hostname,
        options.architecture,
        options.root_password,
        _abspath_or_none(options.root_password_file),
        os.path.abspath(options.resolv_conf),
        options.disk_id,
        options.first_partition_uuid,
        options.machine_id,
        options.bootloader_approach,
        options.bootloader_force,
        options.with_openstack,
    )

    bootstrap = BootstrapEngine(
        messenger,
        executor,
        machine_config,
        _abspath_or_none(options.scripts_dir_pre),
        _abspath_or_none(options.scripts_dir_chroot),
        _abspath_or_none(options.scripts_dir_post),
        os.path.abspath(options.target_path),
        options.command_grub2_install,
    )

    distro_class = getattr(options, DISTRO_CLASS_FIELD)
    bootstrap.set_distro(distro_class.create(messenger, executor, options))

    bootstrap.check_release()
    bootstrap.select_bootloader()
    bootstrap.detect_grub2_install()
    bootstrap.check_for_commands()
    bootstrap.check_architecture()
    bootstrap.check_target_block_device()
    bootstrap.check_script_permissions()
    bootstrap.process_root_password()
    bootstrap.run()

    if not stdout_wanted:
        child_process_stdout.close()

    messenger.info('Done.')
Beispiel #2
0
def _main__level_three(messenger, options):
    stdout_wanted = options.verbosity is VERBOSITY_VERBOSE

    if stdout_wanted:
        child_process_stdout = None
    else:
        child_process_stdout = open('/dev/null', 'w')

    sanitize_path()

    executor = Executor(messenger, stdout=child_process_stdout)

    bootstrapper_class = getattr(options, BOOTSTRAPPER_CLASS_FIELD)
    bootstrap = bootstrapper_class.create(messenger, executor, options)

    bootstrap.check_for_commands()
    if bootstrap.wants_to_be_unshared():
        bootstrap.unshare()
    bootstrap.run()

    if not stdout_wanted:
        child_process_stdout.close()