def create_parser(subparsers): ''' Create a subparser for the submit command :param subparsers: :return: ''' parser = subparsers.add_parser( 'submit', help='Submit a topology', usage="%(prog)s [options] cluster/[role]/[env] " + \ "topology-file-name topology-class-name [topology-args]", add_help=True ) cli_args.add_titles(parser) cli_args.add_cluster_role_env(parser) cli_args.add_topology_file(parser) cli_args.add_topology_class(parser) cli_args.add_config(parser) cli_args.add_deactive_deploy(parser) cli_args.add_dry_run(parser) cli_args.add_extra_launch_classpath(parser) cli_args.add_service_url(parser) cli_args.add_system_property(parser) cli_args.add_verbose(parser) parser.set_defaults(subcommand='submit') return parser
def create_parser(subparsers): """ Create the parse for the update command """ parser = subparsers.add_parser( 'update', help='Update a topology', usage="%(prog)s [options] cluster/[role]/[env] <topology-name> " + "--component-parallelism <name:value>", add_help=True) args.add_titles(parser) args.add_cluster_role_env(parser) args.add_topology(parser) def parallelism_type(value): pattern = re.compile(r"^[\w-]+:[\d]+$") if not pattern.match(value): raise argparse.ArgumentTypeError( 'Invalid syntax for component parallelism (<component_name>:<value>): %s' % value) return value parser.add_argument( '--component-parallelism', action='append', type=parallelism_type, required=True, help='Component name and the new parallelism value ' + 'colon-delimited: [component_name]:[parallelism]') args.add_config(parser) args.add_dry_run(parser) args.add_service_url(parser) args.add_verbose(parser) parser.set_defaults(subcommand='update') return parser
def create_parser(subparsers): ''' :param subparsers: :return: ''' parser = subparsers.add_parser( 'restart', help='Restart a topology', usage="%(prog)s [options] cluster/[role]/[env] <topology-name> [container-id]", add_help=True) args.add_titles(parser) args.add_cluster_role_env(parser) args.add_topology(parser) parser.add_argument( 'container-id', nargs='?', type=int, default=-1, help='Identifier of the container to be restarted') args.add_config(parser) args.add_service_url(parser) args.add_verbose(parser) parser.set_defaults(subcommand='restart') return parser
def create_parser(subparsers): ''' :param subparsers: :return: ''' parser = subparsers.add_parser( 'restart', help='Restart a topology', usage= "%(prog)s [options] cluster/[role]/[env] <topology-name> [container-id]", add_help=True) args.add_titles(parser) args.add_cluster_role_env(parser) args.add_topology(parser) parser.add_argument('container-id', nargs='?', type=int, default=-1, help='Identifier of the container to be restarted') args.add_config(parser) args.add_service_url(parser) args.add_verbose(parser) parser.set_defaults(subcommand='restart') return parser
def create_parser(subparsers): """ Create the parse for the update command """ parser = subparsers.add_parser( 'update', help='Update a topology', usage="%(prog)s [options] cluster/[role]/[env] <topology-name> " + "[--component-parallelism <name:value>] " + "[--runtime-config [component:]<name:value>]", add_help=True) args.add_titles(parser) args.add_cluster_role_env(parser) args.add_topology(parser) args.add_config(parser) args.add_dry_run(parser) args.add_service_url(parser) args.add_verbose(parser) # Special parameters for update command def parallelism_type(value): pattern = re.compile(r"^[\w\.-]+:[\d]+$") if not pattern.match(value): raise argparse.ArgumentTypeError( "Invalid syntax for component parallelism (<component_name:value>): %s" % value) return value parser.add_argument('--component-parallelism', action='append', type=parallelism_type, required=False, help='Component name and the new parallelism value ' + 'colon-delimited: <component_name>:<parallelism>') def runtime_config_type(value): pattern = re.compile(r"^([\w\.-]+:){1,2}[\w\.-]+$") if not pattern.match(value): raise argparse.ArgumentTypeError( "Invalid syntax for runtime config ([component:]<name:value>): %s" % value) return value parser.add_argument( '--runtime-config', action='append', type=runtime_config_type, required=False, help='Runtime configurations for topology and components ' + 'colon-delimited: [component:]<name>:<value>') parser.set_defaults(subcommand='update') return parser
def create_parser(subparsers): """ Create the parse for the update command """ parser = subparsers.add_parser( 'update', help='Update a topology', usage="%(prog)s [options] cluster/[role]/[env] <topology-name> " + "[--component-parallelism <name:value>] " + "[--runtime-config [component:]<name:value>]", add_help=True) args.add_titles(parser) args.add_cluster_role_env(parser) args.add_topology(parser) args.add_config(parser) args.add_dry_run(parser) args.add_service_url(parser) args.add_verbose(parser) # Special parameters for update command def parallelism_type(value): pattern = re.compile(r"^[\w\.-]+:[\d]+$") if not pattern.match(value): raise argparse.ArgumentTypeError( "Invalid syntax for component parallelism (<component_name:value>): %s" % value) return value parser.add_argument( '--component-parallelism', action='append', type=parallelism_type, required=False, help='Component name and the new parallelism value ' + 'colon-delimited: <component_name>:<parallelism>') def runtime_config_type(value): pattern = re.compile(r"^([\w\.-]+:){1,2}[\w\.-]+$") if not pattern.match(value): raise argparse.ArgumentTypeError( "Invalid syntax for runtime config ([component:]<name:value>): %s" % value) return value parser.add_argument( '--runtime-config', action='append', type=runtime_config_type, required=False, help='Runtime configurations for topology and components ' + 'colon-delimited: [component:]<name>:<value>') parser.set_defaults(subcommand='update') return parser
def create_parser(subparsers): ''' :param subparsers: :return: ''' parser = subparsers.add_parser('version', help='Print version of heron-cli', usage="%(prog)s [options] [cluster]", add_help=True) add_version_titles(parser) parser.add_argument('cluster', nargs='?', type=str, default="", help='Name of the cluster') cli_args.add_service_url(parser) parser.set_defaults(subcommand='version') return parser
def create_parser(subparsers, action, help_arg): ''' :param subparsers: :param action: :param help_arg: :return: ''' parser = subparsers.add_parser( action, help=help_arg, usage="%(prog)s [options] cluster/[role]/[env] <topology-name>", add_help=True) args.add_titles(parser) args.add_cluster_role_env(parser) args.add_topology(parser) args.add_config(parser) args.add_service_url(parser) args.add_verbose(parser) parser.set_defaults(subcommand=action) return parser
def create_parser(subparsers): ''' :param subparsers: :return: ''' parser = subparsers.add_parser( 'version', help='Print version of heron-cli', usage="%(prog)s [options] [cluster]", add_help=True) add_version_titles(parser) parser.add_argument( 'cluster', nargs='?', type=str, default="", help='Name of the cluster') cli_args.add_service_url(parser) parser.set_defaults(subcommand='version') return parser