コード例 #1
0
    def Args(parser):
        parser.add_argument(
            '--description',
            help=('An optional, textual description for the snapshots being '
                  'created.'))

        snapshot_names = parser.add_argument(
            '--snapshot-names',
            type=arg_parsers.ArgList(min_length=1),
            action=arg_parsers.FloatingListValuesCatcher(),
            metavar='SNAPSHOT_NAME',
            help='Names to assign to the snapshots.')
        snapshot_names.detailed_help = """\
        Names to assign to the snapshots. Without this option, the
        name of each snapshot will be a random, 16-character
        hexadecimal number that starts with a letter. The values of
        this option run parallel to the disks specified. For example,

          $ {command} my-disk-1 my-disk-2 my-disk-3 --snapshot-name snapshot-1 snapshot-2 snapshot-3

        will result in ``my-disk-1'' being snapshotted as
        ``snapshot-1'', ``my-disk-2'' as ``snapshot-2'', and so on.
        """

        disk = parser.add_argument('disk_names',
                                   metavar='DISK_NAME',
                                   nargs='+',
                                   help='The names of the disks to snapshot.')
        cli = SnapshotDisks.GetCLIGenerator()
        disk.completer = utils.GetCompleterForResource('compute.disks', cli)

        utils.AddZoneFlag(parser,
                          resource_type='disks',
                          operation_type='snapshot',
                          cli=cli)
コード例 #2
0
 def AddArgs(parser, resource=None, cli=None, completer_command=None):
   describe = parser.add_argument(
       'name',
       metavar='NAME',
       help='The name of the resource to fetch.')
   if cli:
     describe.completer = utils.GetCompleterForResource(
         resource, cli, completer_command)
コード例 #3
0
 def AddArgs(parser, resource=None, cli=None, command=None):
   delete = parser.add_argument(
       'names',
       metavar='NAME',
       nargs='+',
       help='The resources to delete.')
   if cli:
     delete.completer = utils.GetCompleterForResource(
         resource, cli, command)
コード例 #4
0
    def Args(parser):
        forwarding_rules_utils.ForwardingRulesMutator.Args(parser)

        delete = parser.add_argument(
            'names',
            metavar='NAME',
            nargs='+',
            help='The names of the forwarding rules to delete.')
        cli = Delete.GetCLIGenerator()
        delete.completer = utils.GetCompleterForResource(
            'compute.forwardingRules', cli, 'compute.forwarding-rules')
コード例 #5
0
    def Args(parser):
        addresses_utils.AddressesMutator.Args(parser)

        delete = parser.add_argument(
            'names',
            metavar='NAME',
            nargs='+',
            help='The names of the addresses to delete.')
        cli = Delete.GetCLIGenerator()
        delete.completer = utils.GetCompleterForResource(
            'compute.addresses', cli)
コード例 #6
0
 def Args(parser, resource=None, cli=None, command=None):
     name = parser.add_argument(
         'name',
         metavar='NAME',
         help='Managed instance group which will no longer be autoscaled.')
     if cli:
         name.completer = utils.GetCompleterForResource(
             resource, cli, command)
     utils.AddZoneFlag(parser,
                       resource_type='resources',
                       operation_type='delete',
                       cli=cli)
コード例 #7
0
 def Args(parser, resource=None, cli=None, command=None):
     autoscaler_util.AddAutoscalerArgs(parser)
     name = parser.add_argument(
         'name',
         metavar='NAME',
         help=
         'Managed instance group which autoscaling parameters will be set.')
     if cli:
         name.completer = utils.GetCompleterForResource(
             resource, cli, command)
     utils.AddZoneFlag(parser,
                       resource_type='resources',
                       operation_type='update',
                       cli=cli)
コード例 #8
0
    def Args(parser):
        auto_delete_metavar = '{' + ','.join(
            AUTO_DELETE_OVERRIDE_CHOICES) + '}'

        auto_delete_override = parser.add_mutually_exclusive_group()

        delete_disks = auto_delete_override.add_argument(
            '--delete-disks',
            choices=AUTO_DELETE_OVERRIDE_CHOICES,
            metavar=auto_delete_metavar,
            help=('The types of disks to delete with instance deletion '
                  "regardless of the disks' auto-delete configuration."))
        delete_disks.detailed_help = """\
        The types of disks to delete with instance deletion regardless
        of the disks' auto-delete configuration. When this flag is
        provided, the auto-delete bits on the attached disks are
        modified accordingly before the instance deletion requests are
        issued. For more information on disk auto-deletion, see
        link:https://developers.google.com/compute/docs/disks#updateautodelete[].
        """

        keep_disks = auto_delete_override.add_argument(
            '--keep-disks',
            choices=AUTO_DELETE_OVERRIDE_CHOICES,
            metavar=auto_delete_metavar,
            help=('The types of disks to not delete with instance deletion '
                  "regardless of the disks' auto-delete configuration."))
        keep_disks.detailed_help = """\
        The types of disks to not delete with instance deletion regardless
        of the disks' auto-delete configuration. When this flag is
        provided, the auto-delete bits on the attached disks are
        modified accordingly before the instance deletion requests are
        issued. For more information on disk auto-deletion, see
        link:https://developers.google.com/compute/docs/disks#updateautodelete[].
        """

        delete = parser.add_argument(
            'names',
            metavar='NAME',
            nargs='+',
            help='The names of the instances to delete.')
        cli = Delete.GetCLIGenerator()
        delete.completer = utils.GetCompleterForResource(
            'compute.instances', cli)

        utils.AddZoneFlag(parser,
                          resource_type='instances',
                          operation_type='delete',
                          cli=cli)
コード例 #9
0
  def Args(parser, resource_type, cli=None, command=None):
    resource = resource_type
    BaseDescriber.AddArgs(parser, 'compute.'+ resource, cli, command)
    AddFieldsFlag(parser, resource_type)

    scope = parser.add_mutually_exclusive_group()

    region = scope.add_argument(
        '--region',
        help='The region of the resource to fetch.',
        action=actions.StoreProperty(properties.VALUES.compute.region))
    if cli:
      region.completer = utils.GetCompleterForResource(
          'compute.regions', cli)

    scope.add_argument(
        '--global',
        action='store_true',
        help=('If provided, it is assumed that the requested resource is '
              'global.'))
コード例 #10
0
ファイル: resize.py プロジェクト: bopopescu/brydzenie
    def Args(parser):
        disk = parser.add_argument('disk_names',
                                   metavar='DISK_NAME',
                                   nargs='+',
                                   help='The names of the disks to resize.')
        cli = Resize.GetCLIGenerator()
        disk.completer = utils.GetCompleterForResource('compute.disks', cli)

        size = parser.add_argument(
            '--size',
            required=True,
            type=arg_parsers.BinarySize(lower_bound='1GB'),
            help='Indicates the new size of the disks.')
        size.detailed_help = """\
        Indicates the new size of the disks. The value must be a whole
        number followed by a size unit of ``KB'' for kilobyte, ``MB''
        for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For
        example, ``10GB'' will produce 10 gigabyte disks.  Disk size
        must be a multiple of 10 GB.
        """

        utils.AddZoneFlag(parser,
                          resource_type='disks',
                          operation_type='be resized')
コード例 #11
0
def _Args(parser, cli_generator):
    """Argument parsing for ssh, including hook for remote completion."""
    ssh_utils.BaseSSHCLICommand.Args(parser)

    parser.add_argument('--command',
                        help='A command to run on the virtual machine.')

    ssh_flags = parser.add_argument(
        '--ssh-flag',
        action='append',
        help='Additional flags to be passed to ssh.')
    ssh_flags.detailed_help = """\
      Additional flags to be passed to *ssh(1)*. It is recommended that flags
      be passed using an assignment operator and quotes. This flag will
      replace occurences of ``%USER%'' and ``%INSTANCE%'' with their
      dereferenced values. Example:

        $ {command} example-instance --zone us-central1-a --ssh-flag="-vvv" --ssh-flag="-L 80:%INSTANCE%:80"

      is equivalent to passing the flags ``--vvv'' and ``-L
      80:162.222.181.197:80'' to *ssh(1)* if the external IP address of
      'example-instance' is 162.222.181.197.
      """

    parser.add_argument('--container',
                        help="""\
          The name of a container inside of the virtual machine instance to
          connect to. This only applies to virtual machines that are using
          a Google container virtual machine image. For more information,
          see link:https://developers.google.com/compute/docs/containers[].
          """)

    user_host = parser.add_argument('user_host',
                                    help='Specifies the instance to SSH into.',
                                    metavar='[USER@]INSTANCE')
    user_host.completer = utils.GetCompleterForResource(
        'compute.instances', cli_generator)
    user_host.detailed_help = """\
      Specifies the instance to SSH into.

      ``USER'' specifies the username with which to SSH. If omitted,
      $USER from the environment is selected.
      """

    implementation_args = parser.add_argument('implementation_args',
                                              nargs='*',
                                              help="""\
          Flags and positionals passed to the underlying ssh implementation.
          """,
                                              metavar='-- IMPLEMENTATION-ARGS')
    implementation_args.detailed_help = """\
      Flags and positionals passed to the underlying ssh implementation.

      The '--' argument must be specified between gcloud specific args on
      the left and IMPLEMENTATION-ARGS on the right. Example:

        $ {command} example-instance --zone us-central1-a -- -vvv -L 80:%INSTANCE%:80
      """

    utils.AddZoneFlag(parser,
                      resource_type='instance',
                      operation_type='connect to',
                      cli=cli_generator)