Ejemplo n.º 1
0
    def Args(cls, parser):
        """Adds arguments to the supplied parser.

    Args:
      parser: The argparse parser to add arguments to.
    """
        cls.VPN_TUNNEL_ARG = (vpn_tunnel_flags.VpnTunnelArgument())
        cls.VPN_TUNNEL_ARG.AddArgument(parser)
        labels_util.AddUpdateLabelsFlags(parser)
Ejemplo n.º 2
0
    def Args(cls, parser):
        """Adds arguments to the supplied parser."""

        cls.ROUTER_ARG = router_flags.RouterArgumentForVpnTunnel(
            required=False)
        cls.TARGET_VPN_GATEWAY_ARG = (
            target_vpn_gateway_flags.TargetVpnGatewayArgumentForVpnTunnel())
        cls.TARGET_VPN_GATEWAY_ARG.AddArgument(parser)
        cls.VPN_TUNNEL_ARG = flags.VpnTunnelArgument()
        cls.VPN_TUNNEL_ARG.AddArgument(parser, operation_type='create')

        parser.add_argument(
            '--description',
            help='An optional, textual description for the target VPN tunnel.')

        parser.add_argument(
            '--ike-version',
            choices=[1, 2],
            type=int,
            help='Internet Key Exchange protocol version number. Default is 2.'
        )

        parser.add_argument(
            '--peer-address',
            required=True,
            help='A valid IP-v4 address representing the remote tunnel endpoint'
        )

        # TODO(b/36053573) Add other group members
        parser.add_argument('--shared-secret',
                            type=ValidateSimpleSharedSecret,
                            required=True,
                            help="""\
        A shared secret consisting of printable characters.  Valid
        arguments match the regular expression """ + _PRINTABLE_CHARS_PATTERN)

        parser.add_argument('--ike-networks',
                            type=arg_parsers.ArgList(min_length=1),
                            help=argparse.SUPPRESS)

        parser.add_argument(
            '--local-traffic-selector',
            type=arg_parsers.ArgList(min_length=1),
            metavar='CIDR',
            help=
            ('Traffic selector is an agreement between IKE peers to permit '
             'traffic through a tunnel if the traffic matches a specified pair'
             ' of local and remote addresses.\n\n'
             'local_traffic_selector allows to configure the local addresses '
             'that are permitted. The value should be a comma separated list '
             'of CIDR formatted strings. '
             'Example: 192.168.0.0/16,10.0.0.0/24.'))

        parser.add_argument(
            '--remote-traffic-selector',
            type=arg_parsers.ArgList(min_length=1),
            metavar='CIDR',
            help=
            ('Traffic selector is an agreement between IKE peers to permit '
             'traffic through a tunnel if the traffic matches a specified pair'
             ' of local and remote addresses.\n\n'
             'remote_traffic_selector allows to configure the remote addresses'
             ' that are permitted. The value should be a comma separated list '
             'of CIDR formatted strings. '
             'Example: 192.168.0.0/16,10.0.0.0/24.'))

        # TODO(b/29072646): autocomplete --router argument
        parser.add_argument('--router',
                            help='The Router to use for dynamic routing.')
Ejemplo n.º 3
0
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.external_vpn_gateways import (
    flags as external_vpn_gateway_flags)
from googlecloudsdk.command_lib.compute.routers import flags as router_flags
from googlecloudsdk.command_lib.compute.target_vpn_gateways import (
    flags as target_vpn_gateway_flags)
from googlecloudsdk.command_lib.compute.vpn_gateways import (flags as
                                                             vpn_gateway_flags)
from googlecloudsdk.command_lib.compute.vpn_tunnels import flags

_PRINTABLE_CHARS_PATTERN = r'[ -~]+'

_ROUTER_ARG = router_flags.RouterArgumentForVpnTunnel(required=False)
_VPN_TUNNEL_ARG = flags.VpnTunnelArgument()


class DeprecatedArgumentException(exceptions.ToolException):
    def __init__(self, arg, msg):
        super(DeprecatedArgumentException,
              self).__init__('{0} is deprecated. {1}'.format(arg, msg))


def ValidateSimpleSharedSecret(possible_secret):
    """ValidateSimpleSharedSecret checks its argument is a vpn shared secret.

  ValidateSimpleSharedSecret(v) returns v iff v matches [ -~]+.

  Args:
    possible_secret: str, The data to validate as a shared secret.
Ejemplo n.º 4
0
 def Args(parser):
     """Adds arguments to the supplied parser."""
     Describe.VPN_TUNNEL_ARG = flags.VpnTunnelArgument()
     Describe.VPN_TUNNEL_ARG.AddArgument(parser, operation_type='describe')
Ejemplo n.º 5
0
"""Command for deleting vpn tunnels."""

from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals

from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.api_lib.compute.operations import poller
from googlecloudsdk.api_lib.compute.vpn_tunnels import vpn_tunnels_utils
from googlecloudsdk.api_lib.util import waiter
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.vpn_tunnels import flags

_VPN_TUNNEL_ARG = flags.VpnTunnelArgument(plural=True)


class DeleteBatchPoller(poller.BatchPoller):
    def GetResult(self, operation_batch):
        # For delete operations, once the operation status is DONE, there is
        # nothing further to fetch.
        return


class Delete(base.DeleteCommand):
    """Delete VPN tunnels.

  *{command}* deletes one or more Google Compute Engine VPN tunnels.
  """
    @staticmethod
Ejemplo n.º 6
0
# limitations under the License.
"""Command to update labels for VPN tunnels."""

from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals

from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.vpn_tunnels import vpn_tunnels_utils
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions as calliope_exceptions
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.vpn_tunnels import flags as vpn_tunnel_flags
from googlecloudsdk.command_lib.util.args import labels_util

_VPN_TUNNEL_ARG = vpn_tunnel_flags.VpnTunnelArgument()


@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Update(base.UpdateCommand):
    r"""Update a Google Compute Engine VPN tunnel.

  *{command}* updates labels for a Google Compute Engine VPN tunnel.
  For example:

    $ {command} example-tunnel --region us-central1 \
      --update-labels=k0=value1,k1=value2 --remove-labels=k3

  will add/update labels ``k0'' and ``k1'' and remove labels with key ``k3''.

  Labels can be used to identify the VPN tunnel and to filter them as in
Ejemplo n.º 7
0
 def Args(parser):
   Delete.VPN_TUNNEL_ARG = flags.VpnTunnelArgument(plural=True)
   Delete.VPN_TUNNEL_ARG.AddArgument(parser, operation_type='delete')
   parser.display_info.AddCacheUpdater(flags.VpnTunnelsCompleter)
Ejemplo n.º 8
0
 def Args(parser):
     Delete.VPN_TUNNEL_ARG = flags.VpnTunnelArgument(plural=True)
     Delete.VPN_TUNNEL_ARG.AddArgument(parser, operation_type='delete')