Ejemplo n.º 1
0
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=False)

    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_verbose(parser)

    parser.set_defaults(subcommand='restart')
    return parser
Ejemplo n.º 2
0
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_extra_launch_classpath(parser)
    cli_args.add_system_property(parser)
    cli_args.add_dry_run(parser)
    cli_args.add_verbose(parser)

    parser.set_defaults(subcommand='submit')
    return parser
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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_verbose(parser)

  parser.set_defaults(subcommand='update')
  return parser
Ejemplo n.º 5
0
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=False
  )

  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_system_property(parser)
  cli_args.add_verbose(parser)

  parser.set_defaults(subcommand='submit')
  return parser
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
def add_additional_args(parsers):
    '''
  add additional parameters to parser
  '''
    for parser in parsers:
        cli_args.add_verbose(parser)
        cli_args.add_config(parser)
        parser.add_argument('--heron-dir',
                            default=config.get_heron_dir(),
                            help='Path to Heron home directory')
Ejemplo n.º 8
0
def add_additional_args(parsers):
  '''
  add additional parameters to parser
  '''
  for parser in parsers:
    cli_args.add_verbose(parser)
    cli_args.add_config(parser)
    parser.add_argument(
        '--heron-dir',
        default=config.get_heron_dir(),
        help='Path to Heron home directory')
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
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_verbose(parser)

    parser.set_defaults(subcommand=action)
    return parser
Ejemplo n.º 12
0
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=False)

  args.add_titles(parser)
  args.add_cluster_role_env(parser)
  args.add_topology(parser)

  args.add_config(parser)
  args.add_verbose(parser)

  parser.set_defaults(subcommand=action)
  return parser