Esempio n. 1
0
def AddImageArgs(parser):
  """Adds arguments related to images for instances and instance-templates."""

  def AddImageHelp():
    return """
          Specifies the boot image for the instances. For each
          instance, a new boot disk will be created from the given
          image. Each boot disk will have the same name as the
          instance.

          {alias_table}

          When using this option, ``--boot-disk-device-name'' and
          ``--boot-disk-size'' can be used to override the boot disk's
          device name and size, respectively.

          By default, ``{default_image}'' is assumed for this flag.
          """.format(
              alias_table=image_utils.GetImageAliasTable(),
              default_image=constants.DEFAULT_IMAGE)

  image_choices = ['IMAGE'] + sorted(constants.IMAGE_ALIASES.keys())
  image = parser.add_argument(
      '--image',
      help='The image that the boot disk will be initialized with.',
      metavar=' | '.join(image_choices))
  image.detailed_help = AddImageHelp
  image_utils.AddImageProjectFlag(parser)
Esempio n. 2
0
def _CommonArgs(parser):
    """Add arguments used for parsing in all command tracks."""
    parser.add_argument(
        '--description',
        help=('An optional, textual description for the disks being created.'))

    size = parser.add_argument('--size',
                               type=arg_parsers.BinarySize(lower_bound='1GB'),
                               help='Indicates the size of the disks.')
    size.detailed_help = """\
      Indicates the 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.
      """

    parser.add_argument('names',
                        metavar='NAME',
                        nargs='+',
                        help='The names of the disks to create.')

    source_group = parser.add_mutually_exclusive_group()

    def AddImageHelp():
        return """\
        An image to apply to the disks being created. When using
        this option, the size of the disks must be at least as large as
        the image size. Use ``--size'' to adjust the size of the disks.

        {alias_table}

        This flag is mutually exclusive with ``--source-snapshot''.
        """.format(alias_table=image_utils.GetImageAliasTable())

    image = source_group.add_argument(
        '--image', help='An image to apply to the disks being created.')
    image.detailed_help = AddImageHelp

    image_utils.AddImageProjectFlag(parser)

    source_snapshot = source_group.add_argument(
        '--source-snapshot',
        help='A source snapshot used to create the disks.')
    source_snapshot.detailed_help = """\
      A source snapshot used to create the disks. It is safe to
      delete a snapshot after a disk has been created from the
      snapshot. In such cases, the disks will no longer reference
      the deleted snapshot. To get a list of snapshots in your
      current project, run `gcloud compute snapshots list`. A
      snapshot from an existing disk can be created using the
      'gcloud compute disks snapshot' command. This flag is mutually
      exclusive with ``--image''.

      When using this option, the size of the disks must be at least
      as large as the snapshot size. Use ``--size'' to adjust the
      size of the disks.
      """

    disk_type = parser.add_argument(
        '--type', help='Specifies the type of disk to create.')
    disk_type.detailed_help = """\
      Specifies the type of disk to create. To get a
      list of available disk types, run 'gcloud compute
      disk-types list'. The default disk type is pd-standard.
      """

    utils.AddZoneFlag(parser, resource_type='disks', operation_type='create')