Ejemplo n.º 1
0
def welcome(prog_name='Anvil', version_text=version.version_string()):
    lower = "| %s |" % (version_text)
    welcome_header = _get_welcome_stack()
    max_line_len = len(max(welcome_header.splitlines(), key=len))
    footer = colorizer.color(prog_name, 'green') + ": " + colorizer.color(lower, 'blue', bold=True)
    uncolored_footer = prog_name + ": " + lower
    if max_line_len - len(uncolored_footer) > 0:
        # This format string will center the uncolored text which
        # we will then replace with the color text equivalent.
        centered_str = center_text(uncolored_footer, " ", max_line_len)
        footer = centered_str.replace(uncolored_footer, footer)
    print(welcome_header)
    print(footer)
    real_max = max(max_line_len, len(uncolored_footer))
    slang = center_text(_welcome_slang(), ' ', real_max)
    print(colorizer.color(slang, 'magenta', bold=True))
    return ("-", real_max)
Ejemplo n.º 2
0
def welcome(prog_name='Anvil', version_text=version.version_string()):
    lower = "| %s |" % (version_text)
    welcome_header = _get_welcome_stack()
    max_line_len = len(max(welcome_header.splitlines(), key=len))
    footer = colorizer.color(prog_name, 'green') + ": " + colorizer.color(lower, 'blue', bold=True)
    uncolored_footer = prog_name + ": " + lower
    if max_line_len - len(uncolored_footer) > 0:
        # This format string will center the uncolored text which
        # we will then replace with the color text equivalent.
        centered_str = center_text(uncolored_footer, " ", max_line_len)
        footer = centered_str.replace(uncolored_footer, footer)
    print(welcome_header)
    print(footer)
    real_max = max(max_line_len, len(uncolored_footer))
    slang = center_text(_welcome_slang(), ' ', real_max)
    print(colorizer.color(slang, 'magenta', bold=True))
    return ("-", real_max)
Ejemplo n.º 3
0
intersphinx_mapping = {"sphinx": ("http://sphinx.pocoo.org", None)}

# The suffix of source filenames.
source_suffix = ".rst"

# The master toctree document.
master_doc = "index"

# General information about the project.
project = "ANVIL"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
release = anvil_version.version_string()
version = anvil_version.canonical_version_string()

# Set the default Pygments syntax
highlight_language = "python"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
show_authors = False

# -- Options for HTML output ---------------------------------------------------
Ejemplo n.º 4
0
def parse(previous_settings=None):

    version_str = "%s v%s" % ('anvil', version.version_string())
    help_formatter = IndentedHelpFormatter(width=120)
    parser = OptionParser(version=version_str, formatter=help_formatter,
                          prog='smithy')

    # Root options
    parser.add_option("-v", "--verbose",
        action="store_true",
        dest="verbose",
        default=False,
        help="make the output logging verbose")
    parser.add_option("--dryrun",
        action="store_true",
        dest="dryrun",
        default=False,
        help=("perform ACTION but do not actually run any of the commands"
              " that would normally complete ACTION"))

    # Install/start/stop/uninstall specific options
    base_group = OptionGroup(parser, "Action specific options")
    base_group.add_option("-p", "--persona",
        action="store",
        type="string",
        dest="persona_fn",
        default=sh.joinpths(settings.PERSONA_DIR, 'in-a-box', 'basic.yaml'),
        metavar="FILE",
        help="persona yaml file to apply (default: %default)")
    base_group.add_option("-a", "--action",
        action="store",
        type="string",
        dest="action",
        metavar="ACTION",
        help="required action to perform: %s" % (_format_list(actions.names())))
    base_group.add_option("-d", "--directory",
        action="store",
        type="string",
        dest="dir",
        metavar="DIR",
        help=("empty root DIR or "
              "DIR with existing components"))
    base_group.add_option("--no-prompt-passwords",
                          action="store_false",
                          dest="prompt_for_passwords",
                          default=True,
                          help="do not prompt the user for passwords")
    base_group.add_option("--no-store-passwords",
        action="store_false",
        dest="store_passwords",
        default=True,
        help="do not store the users passwords into yaml files")
    parser.add_option_group(base_group)

    suffixes = ("Known suffixes 'K' (kilobyte, 1024),"
                " 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)"
                " are supported, 'B' is the default and is ignored")
    status_group = OptionGroup(parser, "Status specific options")
    status_group.add_option('-s', "--show",
        action="callback",
        dest="show_amount",
        type='string',
        metavar="SIZE",
        callback=_size_cb,
        help="show SIZE 'details' when showing component status. " + suffixes)
    parser.add_option_group(status_group)

    pkg_group = OptionGroup(parser, "Packaging specific options")
    pkg_group.add_option('-m', "--match-installed",
        action="store_true",
        dest="match_installed",
        default=False,
        help="when packaging attempt to use the versions that are installed for the components dependencies")
    parser.add_option_group(pkg_group)

    uninstall_group = OptionGroup(parser, "Uninstall specific options")
    uninstall_group.add_option("--purge",
        action="store_true",
        dest="purge_packages",
        default=False,
        help=("assume when a package is not marked as removable that it can be removed (default: %default)"))
    parser.add_option_group(uninstall_group)

    # Extract only what we care about, these will be passed
    # to the constructor of actions as arguments 
    # so don't adjust the naming wily nilly...
    if previous_settings:
        parser.set_defaults(**previous_settings)

    (options, args) = parser.parse_args()
    values = {}
    values['dir'] = (options.dir or "")
    values['dryrun'] = (options.dryrun or False)
    values['action'] = (options.action or "")
    values['persona_fn'] = options.persona_fn
    values['verbose'] = options.verbose
    values['prompt_for_passwords'] = options.prompt_for_passwords
    values['show_amount'] = max(0, options.show_amount)
    values['store_passwords'] = options.store_passwords
    values['match_installed'] = options.match_installed
    values['purge_packages'] = options.purge_packages
    return values
Ejemplo n.º 5
0
def parse(previous_settings=None):

    version_str = "%s v%s" % ('anvil', version.version_string())
    help_formatter = SmithyHelpFormatter(width=120)
    parser = OptionParser(version=version_str,
                          formatter=help_formatter,
                          prog='smithy')

    # Root options
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="make the output logging verbose")

    # Install/start/stop/uninstall specific options
    base_group = OptionGroup(parser, "Action specific options")
    base_group.add_option(
        "-p",
        "--persona",
        action="store",
        type="string",
        dest="persona_fn",
        default=sh.joinpths(settings.PERSONA_DIR, 'in-a-box', 'basic.yaml'),
        metavar="FILE",
        help="persona yaml file to apply (default: %default)")
    base_group.add_option("-a",
                          "--action",
                          action="store",
                          type="string",
                          dest="action",
                          metavar="ACTION",
                          help="required action to perform: %s" %
                          (_format_list(actions.names())))
    base_group.add_option(
        "-o",
        "--origins",
        action="store",
        type="string",
        dest="origins_fn",
        default=sh.joinpths(settings.ORIGINS_DIR, 'master.yaml'),
        metavar="FILE",
        help="yaml file describing where to get openstack sources "
        "from (default: %default)")
    base_group.add_option("--origins-patch",
                          action="store",
                          type="string",
                          dest="origins_patch_fn",
                          default=None,
                          metavar="FILE",
                          help="origins file patch, jsonpath format (rfc6902)")
    base_group.add_option("--distros-patch",
                          action="store",
                          type="string",
                          dest="distros_patch_fn",
                          default=None,
                          metavar="FILE",
                          help="distros file patch, jsonpath format (rfc6902)")
    base_group.add_option(
        "-j",
        "--jobs",
        action="store",
        type="int",
        dest="jobs",
        default=multiprocessing.cpu_count() + 1,
        metavar="JOBS",
        help="number of building jobs to run simultaneously (default: %default)"
    )
    base_group.add_option(
        "-d",
        "--directory",
        action="store",
        type="string",
        dest="dir",
        metavar="DIR",
        default=_get_default_dir(),
        help=(
            "empty root DIR or DIR with existing components (default: %default)"
        ))
    base_group.add_option(
        "--tee-file",
        action="store",
        type="string",
        dest="tee_file",
        metavar="FILE",
        default='/var/log/anvil.log',
        help=("location to store tee of output (default: %default)"))
    parser.add_option_group(base_group)

    build_group = OptionGroup(parser, "Build specific options")
    build_group.add_option('-u',
                           "--usr-only",
                           action="store_true",
                           dest="usr_only",
                           default=False,
                           help=("when packaging only store /usr directory"
                                 " (default: %default)"))
    build_group.add_option("--venv-deploy-dir",
                           action="store",
                           type="string",
                           dest="venv_deploy_dir",
                           default=None,
                           help=("for virtualenv builds, make the virtualenv "
                                 "relocatable to a directory different from "
                                 "build directory"))
    build_group.add_option(
        '-c',
        "--overwrite-configs",
        action="store_true",
        dest="overwrite_configs",
        default=False,
        help=("When packaging do you want rpm to mark config "
              "files with %config or treat them as files and "
              "overwrite them each time on rpm install"))
    parser.add_option_group(build_group)

    # Extract only what we care about, these will be passed
    # to the constructor of actions as arguments
    # so don't adjust the naming wily nilly...
    if previous_settings:
        parser.set_defaults(**previous_settings)

    (options, _args) = parser.parse_args()
    values = {}
    values['dir'] = (options.dir or "")
    values['action'] = (options.action or "")
    values['jobs'] = options.jobs
    values['persona_fn'] = options.persona_fn
    values['origins_fn'] = options.origins_fn
    values['verbose'] = options.verbose
    values['usr_only'] = options.usr_only
    values['tee_file'] = options.tee_file
    values['overwrite_configs'] = options.overwrite_configs
    if options.origins_patch_fn:
        with open(options.origins_patch_fn) as fp:
            values['origins_patch'] = json.load(fp)
    if options.distros_patch_fn:
        with open(options.distros_patch_fn) as fp:
            values['distros_patch'] = json.load(fp)
    values['venv_deploy_dir'] = options.venv_deploy_dir
    return values
Ejemplo n.º 6
0
def parse(previous_settings=None):

    version_str = "%s v%s" % ('anvil', version.version_string())
    help_formatter = IndentedHelpFormatter(width=120)
    parser = OptionParser(version=version_str,
                          formatter=help_formatter,
                          prog='smithy')

    # Root options
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="make the output logging verbose")
    parser.add_option(
        "--dryrun",
        action="store_true",
        dest="dryrun",
        default=False,
        help=("perform ACTION but do not actually run any of the commands"
              " that would normally complete ACTION"))
    parser.add_option(
        '-k',
        "--keyring",
        action="store",
        dest="keyring_path",
        default="/etc/anvil/passwords.cfg",
        help=
        ("read and create passwords using this keyring file (default: %default)"
         ))
    parser.add_option(
        '-e',
        "--encrypt",
        action="store_true",
        dest="keyring_encrypted",
        default=False,
        help=("use a encrypted keyring file (default: %default)"))
    parser.add_option("--no-prompt-passwords",
                      action="store_false",
                      dest="prompt_for_passwords",
                      default=True,
                      help="do not prompt the user for passwords")
    parser.add_option(
        "--no-store-passwords",
        action="store_false",
        dest="store_passwords",
        default=True,
        help="do not save the users passwords into the users keyring")

    # Install/start/stop/uninstall specific options
    base_group = OptionGroup(parser, "Action specific options")
    base_group.add_option(
        "-p",
        "--persona",
        action="store",
        type="string",
        dest="persona_fn",
        default=sh.joinpths(settings.PERSONA_DIR, 'in-a-box', 'basic.yaml'),
        metavar="FILE",
        help="persona yaml file to apply (default: %default)")
    base_group.add_option("-a",
                          "--action",
                          action="store",
                          type="string",
                          dest="action",
                          metavar="ACTION",
                          help="required action to perform: %s" %
                          (_format_list(actions.names())))
    base_group.add_option(
        "-d",
        "--directory",
        action="store",
        type="string",
        dest="dir",
        metavar="DIR",
        help=("empty root DIR or DIR with existing components"))
    parser.add_option_group(base_group)

    suffixes = ("Known suffixes 'K' (kilobyte, 1024),"
                " 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)"
                " are supported, 'B' is the default and is ignored")
    status_group = OptionGroup(parser, "Status specific options")
    status_group.add_option(
        '-s',
        "--show",
        action="callback",
        dest="show_amount",
        type='string',
        metavar="SIZE",
        callback=_size_cb,
        help="show SIZE 'details' when showing component status. " + suffixes)
    parser.add_option_group(status_group)

    pkg_group = OptionGroup(parser, "Packaging specific options")
    pkg_group.add_option(
        '-m',
        "--match-installed",
        action="store_true",
        dest="match_installed",
        default=False,
        help=("when packaging attempt to use the versions that are "
              "installed for the components dependencies"))
    parser.add_option_group(pkg_group)

    install_group = OptionGroup(parser, "Install specific options")
    install_group.add_option(
        '-c',
        "--only-configure",
        action="store_true",
        dest="only_configure",
        default=False,
        help=("when installing only perform the"
              " download and install phases (default: %default)"))
    parser.add_option_group(install_group)

    uninstall_group = OptionGroup(parser, "Uninstall specific options")
    uninstall_group.add_option(
        "--purge",
        action="store_true",
        dest="purge_packages",
        default=False,
        help=("assume when a package is not marked as"
              " removable that it can be removed (default: %default)"))
    parser.add_option_group(uninstall_group)

    # Extract only what we care about, these will be passed
    # to the constructor of actions as arguments
    # so don't adjust the naming wily nilly...
    if previous_settings:
        parser.set_defaults(**previous_settings)

    (options, _args) = parser.parse_args()
    values = {}
    values['dir'] = (options.dir or "")
    values['dryrun'] = (options.dryrun or False)
    values['action'] = (options.action or "")
    values['persona_fn'] = options.persona_fn
    values['verbose'] = options.verbose
    values['only_configure'] = options.only_configure
    values['prompt_for_passwords'] = options.prompt_for_passwords
    values['show_amount'] = max(0, options.show_amount)
    values['store_passwords'] = options.store_passwords
    values['match_installed'] = options.match_installed
    values['purge_packages'] = options.purge_packages
    values['keyring_path'] = options.keyring_path
    values['keyring_encrypted'] = options.keyring_encrypted
    return values
Ejemplo n.º 7
0
def parse(previous_settings=None):

    version_str = "%s v%s" % ('anvil', version.version_string())
    help_formatter = IndentedHelpFormatter(width=120)
    parser = OptionParser(version=version_str, formatter=help_formatter,
                          prog='smithy')

    # Root options
    parser.add_option("-v", "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="make the output logging verbose")
    parser.add_option("--dryrun",
                      action="store_true",
                      dest="dryrun",
                      default=False,
                      help=("perform ACTION but do not actually run any of the commands"
                            " that would normally complete ACTION"))
    parser.add_option('-k', "--keyring",
                      action="store",
                      dest="keyring_path",
                      default="/etc/anvil/passwords.cfg",
                      help=("read and create passwords using this keyring file (default: %default)"))
    parser.add_option('-e', "--encrypt",
                      action="store_true",
                      dest="keyring_encrypted",
                      default=False,
                      help=("use a encrypted keyring file (default: %default)"))
    parser.add_option("--no-prompt-passwords",
                      action="store_false",
                      dest="prompt_for_passwords",
                      default=True,
                      help="do not prompt the user for passwords")
    parser.add_option("--no-store-passwords",
                      action="store_false",
                      dest="store_passwords",
                      default=True,
                      help="do not save the users passwords into the users keyring")

    # Install/start/stop/uninstall specific options
    base_group = OptionGroup(parser, "Action specific options")
    base_group.add_option("-p", "--persona",
                          action="store",
                          type="string",
                          dest="persona_fn",
                          default=sh.joinpths(settings.PERSONA_DIR, 'in-a-box', 'basic.yaml'),
                          metavar="FILE",
                          help="persona yaml file to apply (default: %default)")
    base_group.add_option("-t", "--openstack-version",
                          action="store",
                          type="string",
                          dest="version_fn",
                          default=sh.joinpths(settings.VERSION_DIR, 'default.yaml'),
                          metavar="FILE",
                          help="version yaml file to apply (default: %default)")
    base_group.add_option("-a", "--action",
                          action="store",
                          type="string",
                          dest="action",
                          metavar="ACTION",
                          help="required action to perform: %s" % (_format_list(actions.names())))
    base_group.add_option("-j", "--jobs",
                          action="store",
                          type="int",
                          dest="jobs",
                          default=multiprocessing.cpu_count() + 1,
                          metavar="JOBS",
                          help="number of building jobs to run simultaneously (default: %default)")
    base_group.add_option("-d", "--directory",
                          action="store",
                          type="string",
                          dest="dir",
                          metavar="DIR",
                          help=("empty root DIR or DIR with existing components"))
    parser.add_option_group(base_group)

    suffixes = ("Known suffixes 'K' (kilobyte, 1024),"
                " 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)"
                " are supported, 'B' is the default and is ignored")
    status_group = OptionGroup(parser, "Status specific options")
    status_group.add_option('-s', "--show",
                            action="callback",
                            dest="show_amount",
                            type='string',
                            metavar="SIZE",
                            callback=_size_cb,
                            help="show SIZE 'details' when showing component status. " + suffixes)
    parser.add_option_group(status_group)

    build_group = OptionGroup(parser, "Build specific options")
    build_group.add_option('-u', "--usr-only",
                           action="store_true",
                           dest="usr_only",
                           default=False,
                           help=("when packaging only store /usr directory"
                                 " (default: %default)"))
    parser.add_option_group(build_group)

    # Extract only what we care about, these will be passed
    # to the constructor of actions as arguments
    # so don't adjust the naming wily nilly...
    if previous_settings:
        parser.set_defaults(**previous_settings)

    (options, _args) = parser.parse_args()
    values = {}
    values['dir'] = (options.dir or "")
    values['dryrun'] = (options.dryrun or False)
    values['action'] = (options.action or "")
    values['jobs'] = options.jobs
    values['persona_fn'] = options.persona_fn
    values['version_fn'] = options.version_fn
    values['verbose'] = options.verbose
    values['usr_only'] = options.usr_only
    values['prompt_for_passwords'] = options.prompt_for_passwords
    values['show_amount'] = max(0, options.show_amount)
    values['store_passwords'] = options.store_passwords
    values['keyring_path'] = options.keyring_path
    values['keyring_encrypted'] = options.keyring_encrypted
    return values
Ejemplo n.º 8
0
            if not line or line.startswith("#"):
                continue
            requires.append(line)
    return requires


setuptools.setup(
    name='anvil',
    description='A tool to forge raw OpenStack into a productive tool',
    author='OpenStack Foundation',
    author_email='*****@*****.**',
    url='http://anvil.readthedocs.org/',
    long_description=open("README.rst", 'rb').read(),
    packages=setuptools.find_packages(),
    license='Apache Software License',
    version=version.version_string(),
    scripts=[
        "tools/yyoom",
        "tools/py2rpm",
        "tools/multipip",
        "tools/specprint",
    ],
    install_requires=read_requires("requirements.txt"),
    tests_require=read_requires("test-requirements.txt"),
    classifiers=[
        'Development Status :: 4 - Beta',
        'Environment :: Console',
        'Environment :: OpenStack',
        'Intended Audience :: Information Technology',
        'Intended Audience :: Developers',
        'Intended Audience :: System Administrators',
Ejemplo n.º 9
0
intersphinx_mapping = {'sphinx': ('http://sphinx.pocoo.org', None)}

# The suffix of source filenames.
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'ANVIL'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
release = anvil_version.version_string()
version = anvil_version.canonical_version_string()

# Set the default Pygments syntax
highlight_language = 'python'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
show_authors = False

# -- Options for HTML output ---------------------------------------------------
Ejemplo n.º 10
0
def parse(previous_settings=None):

    version_str = "%s v%s" % ('anvil', version.version_string())
    help_formatter = SmithyHelpFormatter(width=120)
    parser = OptionParser(version=version_str,
                          formatter=help_formatter,
                          prog='smithy')

    # Root options
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="make the output logging verbose")
    parser.add_option(
        "--dryrun",
        action="store_true",
        dest="dryrun",
        default=False,
        help=("perform ACTION but do not actually run any of the commands"
              " that would normally complete ACTION"))
    parser.add_option(
        '-k',
        "--keyring",
        action="store",
        dest="keyring_path",
        default="/etc/anvil/passwords.cfg",
        help=
        ("read and create passwords using this keyring file (default: %default)"
         ))
    parser.add_option(
        '-e',
        "--encrypt",
        action="store_true",
        dest="keyring_encrypted",
        default=False,
        help=("use a encrypted keyring file (default: %default)"))
    parser.add_option("--no-prompt-passwords",
                      action="store_false",
                      dest="prompt_for_passwords",
                      default=True,
                      help="do not prompt the user for passwords")
    parser.add_option(
        "--no-store-passwords",
        action="store_false",
        dest="store_passwords",
        default=True,
        help="do not save the users passwords into the users keyring")

    # Install/start/stop/uninstall specific options
    base_group = OptionGroup(parser, "Action specific options")
    base_group.add_option(
        "-p",
        "--persona",
        action="store",
        type="string",
        dest="persona_fn",
        default=sh.joinpths(settings.PERSONA_DIR, 'in-a-box', 'basic.yaml'),
        metavar="FILE",
        help="persona yaml file to apply (default: %default)")
    base_group.add_option("-a",
                          "--action",
                          action="store",
                          type="string",
                          dest="action",
                          metavar="ACTION",
                          help="required action to perform: %s" %
                          (_format_list(actions.names())))
    base_group.add_option(
        "-j",
        "--jobs",
        action="store",
        type="int",
        dest="jobs",
        default=multiprocessing.cpu_count() + 1,
        metavar="JOBS",
        help="number of building jobs to run simultaneously (default: %default)"
    )
    base_group.add_option(
        "-d",
        "--directory",
        action="store",
        type="string",
        dest="dir",
        metavar="DIR",
        default=_get_default_dir(),
        help=(
            "empty root DIR or DIR with existing components (default: %default)"
        ))
    parser.add_option_group(base_group)

    suffixes = ("Known suffixes 'K' (kilobyte, 1024),"
                " 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)"
                " are supported, 'B' is the default and is ignored")
    status_group = OptionGroup(parser, "Status specific options")
    status_group.add_option(
        '-s',
        "--show",
        action="callback",
        dest="show_amount",
        type='string',
        metavar="SIZE",
        callback=_size_cb,
        help="show SIZE 'details' when showing component status. " + suffixes)
    parser.add_option_group(status_group)

    build_group = OptionGroup(parser, "Build specific options")
    build_group.add_option('-u',
                           "--usr-only",
                           action="store_true",
                           dest="usr_only",
                           default=False,
                           help=("when packaging only store /usr directory"
                                 " (default: %default)"))
    parser.add_option_group(build_group)

    test_group = OptionGroup(parser, "Test specific options")
    test_group.add_option(
        '-i',
        "--ignore-failures",
        action="store_true",
        dest="ignore_test_failures",
        default=False,
        help=("when running tests ignore component test failures"
              " (default: %default)"))
    parser.add_option_group(test_group)

    # Extract only what we care about, these will be passed
    # to the constructor of actions as arguments
    # so don't adjust the naming wily nilly...
    if previous_settings:
        parser.set_defaults(**previous_settings)

    (options, _args) = parser.parse_args()
    values = {}
    values['dir'] = (options.dir or "")
    values['dryrun'] = (options.dryrun or False)
    values['action'] = (options.action or "")
    values['jobs'] = options.jobs
    values['persona_fn'] = options.persona_fn
    values['verbose'] = options.verbose
    values['usr_only'] = options.usr_only
    values['prompt_for_passwords'] = options.prompt_for_passwords
    values['show_amount'] = max(0, options.show_amount)
    values['store_passwords'] = options.store_passwords
    values['keyring_path'] = options.keyring_path
    values['keyring_encrypted'] = options.keyring_encrypted
    values['ignore_test_failures'] = options.ignore_test_failures
    return values
Ejemplo n.º 11
0
def parse():

    prog_name = constants.PROG_NAME
    version_str = "%s v%s" % (prog_name, version.version_string())
    help_formatter = IndentedHelpFormatter(width=HELP_WIDTH)
    parser = OptionParser(version=version_str, formatter=help_formatter)

    # Root options
    parser.add_option("-v", "--verbose",
        action="append_const",
        const=1,
        dest="verbosity",
        default=[1],
        help="increase the verbose level")
    parser.add_option("-o", "--override",
        action="append",
        dest="cli_overrides",
        metavar="OPTION",
        help=("override configuration values (format SECTION/OPTION/VALUE, note "
                "if section is empty 'DEFAULT' is assumed)"))
    parser.add_option("--dryrun",
        action="store_true",
        dest="dryrun",
        default=False,
        help=("perform ACTION but do not actually run any of the commands"
              " that would normally complete ACTION: (default: %default)"))
    opt_help = "configuration file (will be searched for if not provided)"
    parser.add_option("-c", "--config",
        action="store",
        dest="config_fn",
        type="string",
        metavar="FILE",
        help=opt_help)

    # Install/start/stop/uninstall specific options
    base_group = OptionGroup(parser, "Action specific options")
    def_persona = sh.joinpths(settings.PERSONA_DIR, 'devstack.sh.yaml')
    base_group.add_option("-p", "--persona",
        action="store",
        type="string",
        dest="persona_fn",
        default=def_persona,
        metavar="FILE",
        help="persona yaml file to apply (default: %default)")
    base_group.add_option("-a", "--action",
        action="store",
        type="string",
        dest="action",
        metavar="ACTION",
        help="required action to perform: %s" % (_format_list(actions.get_action_names())))
    base_group.add_option("-d", "--directory",
        action="store",
        type="string",
        dest="dir",
        metavar="DIR",
        help=("empty root DIR or "
              "DIR with existing components"))
    base_group.add_option("--no-prompt-passwords",
                          action="store_false",
                          dest="prompt_for_passwords",
                          default=True,
                          help="do not prompt the user for passwords",
                          )
    parser.add_option_group(base_group)

    # Uninstall and stop options
    stop_un_group = OptionGroup(parser, "Uninstall & stop specific options")
    stop_un_group.add_option("-n", "--no-force",
        action="store_true",
        dest="force",
        help="stop the continuation of ACTION if basic errors occur (default: %default)",
        default=False)
    parser.add_option_group(stop_un_group)

    un_group = OptionGroup(parser, "Uninstall specific options")
    un_group.add_option("-k", "--keep-old",
        action="store_true",
        dest="keep_old",
        help="uninstall will keep as much of the old install as it can (default: %default)",
        default=False)
    parser.add_option_group(un_group)

    # Extract only what we care about
    (options, args) = parser.parse_args()
    output = dict()
    output['dir'] = options.dir or ""
    output['dryrun'] = options.dryrun or False
    output['action'] = options.action or ""
    output['force'] = not options.force
    output['keep_old'] = options.keep_old
    output['extras'] = args
    output['config_fn'] = options.config_fn
    output['persona_fn'] = options.persona_fn
    output['verbosity'] = len(options.verbosity)
    output['cli_overrides'] = options.cli_overrides or list()
    output['prompt_for_passwords'] = options.prompt_for_passwords

    return output
Ejemplo n.º 12
0
Archivo: opts.py Proyecto: y2kbot/anvil
def parse(previous_settings=None):

    version_str = "%s v%s" % ('anvil', version.version_string())
    help_formatter = SmithyHelpFormatter(width=120)
    parser = OptionParser(version=version_str, formatter=help_formatter,
                          prog='smithy')

    # Root options
    parser.add_option("-v", "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="make the output logging verbose")

    # Install/start/stop/uninstall specific options
    base_group = OptionGroup(parser, "Action specific options")
    base_group.add_option("-p", "--persona",
                          action="store",
                          type="string",
                          dest="persona_fn",
                          default=sh.joinpths(settings.PERSONA_DIR, 'in-a-box', 'basic.yaml'),
                          metavar="FILE",
                          help="persona yaml file to apply (default: %default)")
    base_group.add_option("-a", "--action",
                          action="store",
                          type="string",
                          dest="action",
                          metavar="ACTION",
                          help="required action to perform: %s" % (_format_list(actions.names())))
    base_group.add_option("-o", "--origins",
                          action="store",
                          type="string",
                          dest="origins_fn",
                          default=sh.joinpths(settings.ORIGINS_DIR, 'master.yaml'),
                          metavar="FILE",
                          help="yaml file describing where to get openstack sources "
                               "from (default: %default)")
    base_group.add_option("--origins-patch",
                          action="store",
                          type="string",
                          dest="origins_patch_fn",
                          default=None,
                          metavar="FILE",
                          help="origins file patch, jsonpath format (rfc6902)")
    base_group.add_option("--distros-patch",
                          action="store",
                          type="string",
                          dest="distros_patch_fn",
                          default=None,
                          metavar="FILE",
                          help="distros file patch, jsonpath format (rfc6902)")
    base_group.add_option("-j", "--jobs",
                          action="store",
                          type="int",
                          dest="jobs",
                          default=multiprocessing.cpu_count() + 1,
                          metavar="JOBS",
                          help="number of building jobs to run simultaneously (default: %default)")
    base_group.add_option("-d", "--directory",
                          action="store",
                          type="string",
                          dest="dir",
                          metavar="DIR",
                          default=_get_default_dir(),
                          help=("empty root DIR or DIR with existing components (default: %default)"))
    parser.add_option_group(base_group)

    build_group = OptionGroup(parser, "Build specific options")
    build_group.add_option('-u', "--usr-only",
                           action="store_true",
                           dest="usr_only",
                           default=False,
                           help=("when packaging only store /usr directory"
                                 " (default: %default)"))
    build_group.add_option("--venv-deploy-dir",
                           action="store",
                           type="string",
                           dest="venv_deploy_dir",
                           default=None,
                           help=("for virtualenv builds, make the virtualenv "
                                 "relocatable to a directory different from "
                                 "build directory"))
    parser.add_option_group(build_group)

    # Extract only what we care about, these will be passed
    # to the constructor of actions as arguments
    # so don't adjust the naming wily nilly...
    if previous_settings:
        parser.set_defaults(**previous_settings)

    (options, _args) = parser.parse_args()
    values = {}
    values['dir'] = (options.dir or "")
    values['action'] = (options.action or "")
    values['jobs'] = options.jobs
    values['persona_fn'] = options.persona_fn
    values['origins_fn'] = options.origins_fn
    values['verbose'] = options.verbose
    values['usr_only'] = options.usr_only
    if options.origins_patch_fn:
        with open(options.origins_patch_fn) as fp:
            values['origins_patch'] = json.load(fp)
    if options.distros_patch_fn:
        with open(options.distros_patch_fn) as fp:
            values['distros_patch'] = json.load(fp)
    values['venv_deploy_dir'] = options.venv_deploy_dir
    return values
Ejemplo n.º 13
0
def parse(previous_settings=None):

    version_str = "%s v%s" % ("anvil", version.version_string())
    help_formatter = SmithyHelpFormatter(width=120)
    parser = OptionParser(version=version_str, formatter=help_formatter, prog="smithy")

    # Root options
    parser.add_option(
        "-v", "--verbose", action="store_true", dest="verbose", default=False, help="make the output logging verbose"
    )
    parser.add_option(
        "--dryrun",
        action="store_true",
        dest="dryrun",
        default=False,
        help=("perform ACTION but do not actually run any of the commands" " that would normally complete ACTION"),
    )
    parser.add_option(
        "-k",
        "--keyring",
        action="store",
        dest="keyring_path",
        default="/etc/anvil/passwords.cfg",
        help=("read and create passwords using this keyring file (default: %default)"),
    )
    parser.add_option(
        "-e",
        "--encrypt",
        action="store_true",
        dest="keyring_encrypted",
        default=False,
        help=("use a encrypted keyring file (default: %default)"),
    )
    parser.add_option(
        "--no-prompt-passwords",
        action="store_false",
        dest="prompt_for_passwords",
        default=True,
        help="do not prompt the user for passwords",
    )
    parser.add_option(
        "--no-store-passwords",
        action="store_false",
        dest="store_passwords",
        default=True,
        help="do not save the users passwords into the users keyring",
    )

    # Install/start/stop/uninstall specific options
    base_group = OptionGroup(parser, "Action specific options")
    base_group.add_option(
        "-p",
        "--persona",
        action="store",
        type="string",
        dest="persona_fn",
        default=sh.joinpths(settings.PERSONA_DIR, "in-a-box", "basic.yaml"),
        metavar="FILE",
        help="persona yaml file to apply (default: %default)",
    )
    base_group.add_option(
        "-a",
        "--action",
        action="store",
        type="string",
        dest="action",
        metavar="ACTION",
        help="required action to perform: %s" % (_format_list(actions.names())),
    )
    base_group.add_option(
        "-o",
        "--origins",
        action="store",
        type="string",
        dest="origins_fn",
        default=sh.joinpths(settings.ORIGINS_DIR, "master.yaml"),
        metavar="FILE",
        help="yaml file describing where to get openstack sources " "from (default: %default)",
    )
    base_group.add_option(
        "-j",
        "--jobs",
        action="store",
        type="int",
        dest="jobs",
        default=multiprocessing.cpu_count() + 1,
        metavar="JOBS",
        help="number of building jobs to run simultaneously (default: %default)",
    )
    base_group.add_option(
        "-d",
        "--directory",
        action="store",
        type="string",
        dest="dir",
        metavar="DIR",
        default=_get_default_dir(),
        help=("empty root DIR or DIR with existing components (default: %default)"),
    )
    parser.add_option_group(base_group)

    suffixes = (
        "Known suffixes 'K' (kilobyte, 1024),"
        " 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)"
        " are supported, 'B' is the default and is ignored"
    )
    status_group = OptionGroup(parser, "Status specific options")
    status_group.add_option(
        "-s",
        "--show",
        action="callback",
        dest="show_amount",
        type="string",
        metavar="SIZE",
        callback=_size_cb,
        help="show SIZE 'details' when showing component status. " + suffixes,
    )
    parser.add_option_group(status_group)

    build_group = OptionGroup(parser, "Build specific options")
    build_group.add_option(
        "-u",
        "--usr-only",
        action="store_true",
        dest="usr_only",
        default=False,
        help=("when packaging only store /usr directory" " (default: %default)"),
    )
    parser.add_option_group(build_group)

    test_group = OptionGroup(parser, "Test specific options")
    test_group.add_option(
        "-i",
        "--ignore-failures",
        action="store_true",
        dest="ignore_test_failures",
        default=False,
        help=("when running tests ignore component test failures" " (default: %default)"),
    )
    parser.add_option_group(test_group)

    # Extract only what we care about, these will be passed
    # to the constructor of actions as arguments
    # so don't adjust the naming wily nilly...
    if previous_settings:
        parser.set_defaults(**previous_settings)

    (options, _args) = parser.parse_args()
    values = {}
    values["dir"] = options.dir or ""
    values["dryrun"] = options.dryrun or False
    values["action"] = options.action or ""
    values["jobs"] = options.jobs
    values["persona_fn"] = options.persona_fn
    values["origins_fn"] = options.origins_fn
    values["verbose"] = options.verbose
    values["usr_only"] = options.usr_only
    values["prompt_for_passwords"] = options.prompt_for_passwords
    values["show_amount"] = max(0, options.show_amount)
    values["store_passwords"] = options.store_passwords
    values["keyring_path"] = options.keyring_path
    values["keyring_encrypted"] = options.keyring_encrypted
    values["ignore_test_failures"] = options.ignore_test_failures
    return values