def create_parser(cli_plugins, out_plugins): parser = argparse.ArgumentParser( description='Command line interface to Lago', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-l', '--loglevel', default='info', choices=['info', 'debug', 'error', 'warning'], help='Log level to use') parser.add_argument('--logdepth', default=3, type=int, help='How many task levels to show') try: # Checks that all the deps are installed pkg_resources.require("lago")[0] except pkg_resources.VersionConflict as e: # Hack that allows to run stevedore without checking # for it's dep. it is required for systems running stevedore 1.1.0 # and pbr > 1. LOGGER.debug(e.message) pkgs = e[2] if len(pkgs) > 1 or 'stevedore' not in pkgs: raise e parser.add_argument( '--version', action='version', version='%(prog)s ' + pkg_resources.get_distribution("lago").version, ) parser.add_argument( '--out-format', '-f', action='store', default='default', choices=out_plugins.keys(), ) parser.add_argument( '--prefix-path', '-p', action='store', default=None, help=('Path to the prefix to use, will be deprecated, use ' '--workdir-path instead'), ) parser.add_argument( '--workdir-path', '-w', action='store', default=None, help='Path to the workdir to use.', ) parser.add_argument( '--prefix-name', '-P', action='store', default='current', dest='prefix_name', help='Name of the prefix to use.', ) parser.add_argument( '--ssh-user', action='store', default='root', help='User for SSH provider.', ) parser.add_argument( '--ssh-password', action='store', default='123456', help='Password for SSH provider.', ) parser.add_argument( '--ssh-tries', action='store', default=100, type=int, help='Number of ssh time outs to wait before failing.', ) parser.add_argument( '--ssh-timeout', action='store', default=10, type=int, help='Seconds to wait before marking SSH connection as failed.') parser.add_argument('--libvirt_url', action='store', default='qemu:///system', help='libvirt URI, currently only ' 'system' ' is supported.') parser.add_argument( '--libvirt-user', action='store', help='libvirt user', ) parser.add_argument( '--libvirt-password', action='store', help='libvirt password', ) parser.add_argument( '--default_vm_type', action='store', default='default', help='Default vm type', ) parser.add_argument( '--default_vm_provider', action='store', default='local-libvirt', help='Default vm provider', ) parser.add_argument( '--default_root_password', action='store', default='123456', help='Default root password', ) parser.add_argument('--lease_dir', action='store', default='/var/lib/lago/subnets', help='Path to store created subnets configurations') parser.add_argument( '--reposync-dir', action='store', default='/var/lib/lago/reposync', help='Reposync dir if used', ) parser.add_argument( '--reposync-config', help='Reposync config', default='config.repo', action='store', ) parser.add_argument('--ignore-warnings', action='store_true') parser.set_defaults(**config.get_section('lago', {})) verbs_parser = parser.add_subparsers(dest='verb', metavar='VERB') for cli_plugin_name, cli_plugin in cli_plugins.items(): plugin_parser = verbs_parser.add_parser( name=cli_plugin_name, formatter_class=argparse.ArgumentDefaultsHelpFormatter, **cli_plugin.init_args) cli_plugin.populate_parser(plugin_parser) plugin_parser.set_defaults(**config.get_section(cli_plugin_name, {})) config.update_parser(parser=parser) return parser
def create_parser(cli_plugins, out_plugins): parser = argparse.ArgumentParser( description='Command line interface to Lago', formatter_class=argparse.ArgumentDefaultsHelpFormatter ) parser.add_argument( '-l', '--loglevel', default='info', choices=['info', 'debug', 'error', 'warning'], help='Log level to use' ) parser.add_argument( '--logdepth', default=3, type=int, help='How many task levels to show' ) try: # Checks that all the deps are installed pkg_resources.require("lago")[0] except pkg_resources.VersionConflict as e: # Hack that allows to run stevedore without checking # for it's dep. it is required for systems running stevedore 1.1.0 # and pbr > 1. LOGGER.debug(e.message) pkgs = e[2] if len(pkgs) > 1 or 'stevedore' not in pkgs: raise e parser.add_argument( '--version', action='version', version='%(prog)s ' + pkg_resources.get_distribution("lago").version, ) parser.add_argument( '--out-format', '-f', action='store', default='default', choices=out_plugins.keys(), ) parser.add_argument( '--prefix-path', '-p', action='store', default=None, help=( 'Path to the prefix to use, will be deprecated, use ' '--workdir-path instead' ), ) parser.add_argument( '--workdir-path', '-w', action='store', default=None, help='Path to the workdir to use.', ) parser.add_argument( '--prefix-name', '-P', action='store', default='current', dest='prefix_name', help='Name of the prefix to use.', ) parser.add_argument( '--ssh-user', action='store', default='root', help='User for SSH provider.', ) parser.add_argument( '--ssh-password', action='store', default='123456', help='Password for SSH provider.', ) parser.add_argument( '--ssh-tries', action='store', default=100, type=int, help='Number of ssh time outs to wait before failing.', ) parser.add_argument( '--ssh-timeout', action='store', default=10, type=int, help='Seconds to wait before marking SSH connection as failed.' ) parser.add_argument( '--libvirt_url', action='store', default='qemu:///system', help='libvirt URI, currently only ' 'system' ' is supported.' ) parser.add_argument( '--libvirt-user', action='store', help='libvirt user', ) parser.add_argument( '--libvirt-password', action='store', help='libvirt password', ) parser.add_argument( '--default_vm_type', action='store', default='default', help='Default vm type', ) parser.add_argument( '--default_vm_provider', action='store', default='local-libvirt', help='Default vm provider', ) parser.add_argument( '--default_root_password', action='store', default='123456', help='Default root password', ) parser.add_argument( '--lease_dir', action='store', default='/var/lib/lago/subnets', help='Path to store created subnets configurations' ) parser.add_argument( '--reposync-dir', action='store', default='/var/lib/lago/reposync', help='Reposync dir if used', ) parser.add_argument( '--reposync-config', help='Reposync config', default='config.repo', action='store', ) parser.add_argument('--ignore-warnings', action='store_true') parser.set_defaults(**config.get_section('lago', {})) verbs_parser = parser.add_subparsers(dest='verb', metavar='VERB') for cli_plugin_name, cli_plugin in cli_plugins.items(): plugin_parser = verbs_parser.add_parser( name=cli_plugin_name, formatter_class=argparse.ArgumentDefaultsHelpFormatter, **cli_plugin.init_args ) cli_plugin.populate_parser(plugin_parser) plugin_parser.set_defaults(**config.get_section(cli_plugin_name, {})) config.update_parser(parser=parser) return parser
def create_parser(cli_plugins, out_plugins): parser = argparse.ArgumentParser( description='Command line interface to Lago', formatter_class=argparse.ArgumentDefaultsHelpFormatter ) parser.add_argument( '-l', '--loglevel', choices=['info', 'debug', 'error', 'warning'], help='Log level to use' ) parser.add_argument( '--logdepth', type=int, help='How many task levels to show' ) parser.add_argument( '--version', action='version', version='%(prog)s ' + pkg_resources.get_distribution("lago").version, ) parser.add_argument( '--out-format', '-f', action='store', default='default', choices=out_plugins.keys(), ) parser.add_argument( '--prefix-path', '-p', action='store', default=None, help=( 'Path to the prefix to use, will be deprecated, use ' '--workdir-path instead' ), ) parser.add_argument( '--workdir-path', '-w', action='store', default=None, help='Path to the workdir to use.', ) parser.add_argument( '--prefix-name', '-P', action='store', help='Name of the prefix to use.', ) parser.add_argument( '--ssh-user', action='store', help='User for SSH provider.', ) parser.add_argument( '--ssh-password', action='store', help='Password for SSH provider.', ) parser.add_argument( '--ssh-tries', action='store', type=int, help='Number of ssh time outs to wait before failing.', ) parser.add_argument( '--ssh-timeout', action='store', type=int, help='Seconds to wait before marking SSH connection as failed.' ) parser.add_argument( '--libvirt_url', action='store', help='libvirt URI, currently only ' 'system' ' is supported.' ) parser.add_argument( '--libvirt-user', action='store', help='libvirt user', ) parser.add_argument( '--libvirt-password', action='store', help='libvirt password', ) parser.add_argument( '--default_vm_type', action='store', help='Default vm type', ) parser.add_argument( '--default_vm_provider', action='store', help='Default vm provider', ) parser.add_argument( '--default_root_password', action='store', help='Default root password', ) parser.add_argument( '--lease_dir', action='store', help='Path to store created subnets configurations' ) parser.add_argument( '--reposync-dir', action='store', help='Reposync dir if used', ) parser.add_argument('--ignore-warnings', action='store_true') parser.set_defaults(**config.get_section('lago', {})) verbs_parser = parser.add_subparsers(dest='verb', metavar='VERB') for cli_plugin_name, cli_plugin in cli_plugins.items(): plugin_parser = verbs_parser.add_parser( name=cli_plugin_name, formatter_class=argparse.ArgumentDefaultsHelpFormatter, **cli_plugin.init_args ) cli_plugin.populate_parser(plugin_parser) plugin_parser.set_defaults(**config.get_section(cli_plugin_name, {})) config.update_parser(parser=parser) return parser
def create_parser(cli_plugins, out_plugins): parser = argparse.ArgumentParser( description='Command line interface to Lago', formatter_class=argparse.ArgumentDefaultsHelpFormatter ) parser.add_argument( '-l', '--loglevel', choices=['info', 'debug', 'error', 'warning'], help='Log level to use' ) parser.add_argument( '--logdepth', type=int, help='How many task levels to show' ) parser.add_argument( '--version', action='version', version='%(prog)s ' + pkg_resources.get_distribution("lago").version, ) parser.add_argument( '--out-format', '-f', action='store', default='default', choices=out_plugins.keys(), ) parser.add_argument( '--prefix-path', '-p', action='store', default=None, help=( 'Path to the prefix to use, will be deprecated, use ' '--workdir-path instead' ), ) parser.add_argument( '--workdir-path', '-w', action='store', default=None, help='Path to the workdir to use.', ) parser.add_argument( '--prefix-name', '-P', action='store', help='Name of the prefix to use.', ) parser.add_argument( '--ssh-user', action='store', help='User for SSH provider.', ) parser.add_argument( '--ssh-password', action='store', help='Password for SSH provider.', ) parser.add_argument( '--ssh-tries', action='store', type=int, help='Number of ssh time outs to wait before failing.', ) parser.add_argument( '--ssh-timeout', action='store', type=int, help='Seconds to wait before marking SSH connection as failed.' ) parser.add_argument( '--libvirt_url', action='store', help='libvirt URI, currently only ' 'system' ' is supported.' ) parser.add_argument( '--libvirt-user', action='store', help='libvirt user', ) parser.add_argument( '--libvirt-password', action='store', help='libvirt password', ) parser.add_argument( '--default_vm_type', action='store', help='Default vm type', ) parser.add_argument( '--default_vm_provider', action='store', help='Default vm provider', ) parser.add_argument( '--default_root_password', action='store', help='Default root password', ) parser.add_argument( '--lease_dir', action='store', help='Path to store created subnets configurations' ) parser.add_argument( '--reposync-dir', action='store', help='Reposync dir if used', ) parser.add_argument('--ignore-warnings', action='store_true') parser.set_defaults(**config.get_section('lago', {})) verbs_parser = parser.add_subparsers(dest='verb', metavar='VERB') for cli_plugin_name, cli_plugin in cli_plugins.items(): plugin_parser = verbs_parser.add_parser( name=cli_plugin_name, formatter_class=argparse.ArgumentDefaultsHelpFormatter, **cli_plugin.init_args ) cli_plugin.populate_parser(plugin_parser) plugin_parser.set_defaults(**config.get_section(cli_plugin_name, {})) config.update_parser(parser=parser) return parser