Exemple #1
0
def _main__level_two():
    parser = argparse.ArgumentParser()
    parser.add_argument('--version', action='version', version=VERSION_STR)

    add_output_control_options(parser)

    general = parser.add_argument_group('general configuration')
    add_general_directory_bootstrapping_options(general)

    system = parser.add_argument_group('system configuration')
    system.add_argument(
        '--resolv-conf',
        metavar='FILE',
        default='/etc/resolv.conf',
        help='file to copy nameserver entries from (default: %(default)s)')

    distros = parser.add_subparsers(
        title='subcommands (choice of distribution)',
        description='Run "%(prog)s DISTRIBUTION --help" for details '
        'on options specific to that distribution.',
        metavar='DISTRIBUTION',
        help='choice of distribution, pick from:')

    for strategy_clazz in (
            ArchBootstrapper,
            GentooBootstrapper,
    ):
        strategy_clazz.add_parser_to(distros)

    parser.add_argument('target_dir', metavar='DIRECTORY')

    options = parser.parse_args()

    messenger = Messenger(options.verbosity, is_color_wanted(options))
    run_handle_errors(_main__level_three, messenger, options)
Exemple #2
0
def _main__level_two():
    parser = ArgumentParser(
        prog='image-bootstrap',
        description=DESCRIPTION,
        epilog=BANNER,
        formatter_class=RawDescriptionHelpFormatter,
    )
    parser.add_argument('--version', action='version', version=VERSION_STR)

    add_output_control_options(parser)

    machine = parser.add_argument_group('machine configuration')
    machine.add_argument('--arch',
                         dest='architecture',
                         default='amd64',
                         help='architecture (e.g. amd64)')
    machine.add_argument(
        '--bootloader',
        dest='bootloader_approach',
        default=BOOTLOADER__AUTO,
        choices=_BOOTLOADER_APPROACHES,
        help=
        'approach to take during bootloader installation (default: %(default)s)'
    )
    machine.add_argument(
        '--bootloader-force',
        default=False,
        action='store_true',
        help='apply more force when installing bootloader (default: disabled)')
    machine.add_argument('--hostname',
                         default='machine',
                         metavar='NAME',
                         help='hostname to set (default: "%(default)s")')
    machine.add_argument(
        '--openstack',
        dest='with_openstack',
        default=False,
        action='store_true',
        help='prepare for use with OpenStack (default: disabled)')
    password_options = machine.add_mutually_exclusive_group()
    password_options.add_argument(
        '--password',
        dest='root_password',
        metavar='PASSWORD',
        help='root password to set (default: password log-in disabled)')
    password_options.add_argument(
        '--password-file',
        dest='root_password_file',
        metavar='FILE',
        help=
        'file to read root password from (default: password log-in disabled)')
    machine.add_argument(
        '--resolv-conf',
        metavar='FILE',
        default='/etc/resolv.conf',
        help='file to copy nameserver entries from (default: %(default)s)')
    machine.add_argument(
        '--disk-id',
        dest='disk_id',
        metavar='ID',
        type=disk_id_type,
        help='specific disk identifier to apply, e.g. 0x12345678')
    machine.add_argument(
        '--first-partition-uuid',
        dest='first_partition_uuid',
        metavar='UUID',
        type=uuid_type,
        help=
        'specific UUID to apply to first partition, e.g. c1b9d5a2-f162-11cf-9ece-0020afc76f16'
    )
    machine.add_argument(
        '--machine-id',
        dest='machine_id',
        metavar='ID',
        type=machine_id_type,
        help=
        'specific machine identifier to apply, e.g. c1b9d5a2f16211cf9ece0020afc76f16'
    )

    script_dirs = parser.add_argument_group('script integration')
    script_dirs.add_argument(
        '--scripts-pre',
        dest='scripts_dir_pre',
        metavar='DIRECTORY',
        help='scripts to run prior to chrooting phase, in alphabetical order')
    script_dirs.add_argument(
        '--scripts-chroot',
        dest='scripts_dir_chroot',
        metavar='DIRECTORY',
        help='scripts to run during chrooting phase, in alphabetical order')
    script_dirs.add_argument(
        '--scripts-post',
        dest='scripts_dir_post',
        metavar='DIRECTORY',
        help='scripts to run after chrooting phase, in alphabetical order')

    commands = parser.add_argument_group('command names')
    commands.add_argument('--grub2-install',
                          metavar='COMMAND',
                          dest='command_grub2_install',
                          help='override grub2-install command')

    general = parser.add_argument_group('general configuration')
    add_general_directory_bootstrapping_options(general)

    distros = parser.add_subparsers(
        title='subcommands (choice of distribution)',
        description='Run "%(prog)s DISTRIBUTION --help" for details '
        'on options specific to that distribution.',
        metavar='DISTRIBUTION',
        help='choice of distribution, pick from:')

    for strategy_clazz in (
            ArchStrategy,
            DebianStrategy,
            GentooStrategy,
            UbuntuStrategy,
    ):
        strategy_clazz.add_parser_to(distros)

    parser.add_argument('target_path',
                        metavar='DEVICE',
                        help='block device to install to')

    options = parser.parse_args()

    messenger = Messenger(options.verbosity, is_color_wanted(options))
    run_handle_errors(_main__level_three, messenger, options)