Example #1
0
def _Args(parser, include_alpha_targets, include_beta_targets):
  """Argument parsing."""
  flags.AddCommonFlags(parser)
  flags.AddUpdateArgs(parser, include_alpha_targets, include_beta_targets)

  address = parser.add_argument(
      '--address',
      help='The external IP address that the forwarding rule will serve.')
  address.detailed_help = """\
      The external IP address that the forwarding rule will
      serve. All traffic sent to this IP address is directed to the
      target pointed to by the forwarding rule. If the address is
      reserved, it must either (1) reside in the global scope if the
      forwarding rule is being configured to point to a target HTTP
      proxy or (2) reside in the same region as the forwarding rule
      if the forwarding rule is being configured to point to a
      target pool or target instance. If this flag is omitted, an
      ephemeral IP address is assigned.
      """
  v1_messages = core_apis.GetMessagesModule('compute', 'v1')
  ip_protocol = parser.add_argument(
      '--ip-protocol',
      choices=_SupportedProtocols(v1_messages),
      type=lambda x: x.upper(),
      help='The IP protocol that the rule will serve.')
  ip_protocol.detailed_help = """\
      The IP protocol that the rule will serve. If left empty, TCP
      is used. Supported protocols are: {0}.
      """.format(', '.join(_SupportedProtocols(v1_messages)))

  parser.add_argument(
      '--description',
      help='An optional textual description for the forwarding rule.')

  ports_scope = parser.add_mutually_exclusive_group()
  ports = ports_scope.add_argument(
      '--ports',
      metavar='[PORT | PORT-PORT]',
      help=('If specified, only packets addressed to the ports or '
            'port ranges will be forwarded.'),
      type=arg_parsers.ArgList(
          min_length=1, element_type=arg_parsers.Range.Parse),
      default=[])

  ports.detailed_help = """\
          If specified, only packets addressed to ports in the specified
          list will be forwarded. If not specified for regional forwarding
          rules, all ports are matched. This flag is required for global
          forwarding rules and accepts a single continuous set of ports.

          Individual ports and ranges can be specified,
          for example (`--ports 8000-8004` or `--ports 80`).
          """
  port_range = ports_scope.add_argument(
      '--port-range',
      type=arg_parsers.Range.Parse,
      help='DEPRECATED, use --ports. If specified, only packets addressed to '
           'the port or ports in the specified range will be forwarded.',
      metavar='[PORT | PORT-PORT]')
  port_range.detailed_help = """\
Example #2
0
def _Args(parser, include_beta, include_alpha=False):
    """Argument parsing."""
    flags.AddCommonFlags(parser)
    flags.AddUpdateArgs(parser, include_beta=include_beta)
    flags.AddAddress(parser)
    flags.AddIPProtocols(parser, include_alpha=include_alpha)
    flags.AddDescription(parser)
    flags.AddPortsAndPortRange(parser)
Example #3
0
    def Args(parser):
        flags.AddCommonFlags(parser)

        parser.add_argument(
            'names',
            metavar='NAME',
            nargs='+',
            completion_resource='compute.forwarding-rules',
            help='The names of the forwarding rules to delete.')
Example #4
0
def _Args(parser, include_alpha_targets):
    """Argument parsing."""
    flags.AddCommonFlags(parser)
    flags.AddUpdateArgs(parser, include_alpha_targets)

    address = parser.add_argument(
        '--address',
        help='The external IP address that the forwarding rule will serve.')
    address.detailed_help = """\
      The external IP address that the forwarding rule will
      serve. All traffic sent to this IP address is directed to the
      target pointed to by the forwarding rule. If the address is
      reserved, it must either (1) reside in the global scope if the
      forwarding rule is being configured to point to a target HTTP
      proxy or (2) reside in the same region as the forwarding rule
      if the forwarding rule is being configured to point to a
      target pool or target instance. If this flag is omitted, an
      ephemeral IP address is assigned.
      """
    v1_messages = core_apis.GetMessagesModule('compute', 'v1')
    ip_protocol = parser.add_argument(
        '--ip-protocol',
        choices=_SupportedProtocols(v1_messages),
        type=lambda x: x.upper(),
        help='The IP protocol that the rule will serve.')
    ip_protocol.detailed_help = """\
      The IP protocol that the rule will serve. If left empty, TCP
      is used. Supported protocols are: {0}.
      """.format(', '.join(_SupportedProtocols(v1_messages)))

    parser.add_argument(
        '--description',
        help='An optional textual description for the forwarding rule.')

    port_range = parser.add_argument(
        '--port-range',
        help=('If specified, only packets addressed to the port or '
              'ports in the specified range will be forwarded.'),
        metavar='[PORT | PORT-PORT]')
    port_range.detailed_help = """\
Example #5
0
 def Args(parser):
   flags.AddCommonFlags(parser)
   flags.AddUpdateArgs(parser,
                       include_alpha_targets=True,
                       include_beta_targets=True)
Example #6
0
 def Args(parser):
     flags.AddCommonFlags(parser)
     flags.AddUpdateArgs(parser, include_beta=True)
Example #7
0
 def Args(parser):
     flags.AddCommonFlags(parser)
     flags.AddUpdateArgs(parser, include_alpha_targets=False)