Exemple #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
Exemple #2
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
Exemple #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
Exemple #4
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
Exemple #5
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
Exemple #6
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
Exemple #7
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
Exemple #8
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