示例#1
0
def _CommonArgs(parser):
  """Add parser arguments common to all tracks."""

  instance_flags.INSTANCE_ARG.AddArgument(parser)

  parser.add_argument(
      '--device-name',
      help=('An optional name that indicates the disk name the guest '
            'operating system will see. (Note: Device name does not '
            'correspond to mounted volume name)'))

  parser.add_argument(
      '--disk',
      help='The name of the disk to attach to the instance.',
      required=True)

  mode = parser.add_argument(
      '--mode',
      choices=MODE_OPTIONS,
      default='rw',
      help='Specifies the mode of the disk.')
  mode.detailed_help = """\
      Specifies the mode of the disk. Supported options are ``ro'' for
      read-only and ``rw'' for read-write. If omitted, ``rw'' is used as
      a default. It is an error to attach a disk in read-write mode to
      more than one instance.
      """

  csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)
示例#2
0
def _CommonArgs(parser, source_snapshot_arg):
    """Add arguments used for parsing in all command tracks."""
    Create.disks_arg.AddArgument(parser, operation_type='create')
    parser.add_argument(
        '--description',
        help='An optional, textual description for the disks being created.')

    parser.add_argument('--size',
                        type=arg_parsers.BinarySize(
                            lower_bound='1GB',
                            suggested_binary_size_scales=[
                                'GB', 'GiB', 'TB', 'TiB', 'PiB', 'PB'
                            ]),
                        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('--type',
                        completion_resource='compute.diskTypes',
                        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.
      """)

    _SourceArgs(parser, source_snapshot_arg)

    csek_utils.AddCsekKeyArgs(parser)
    labels_util.AddCreateLabelsFlags(parser)
示例#3
0
def _CommonArgs(parser):
  """Add parser arguments common to all tracks."""
  SnapshotDisks.disks_arg.AddArgument(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),
      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-names 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.
      """
  csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)
示例#4
0
def _Args(parser,
          release_track,
          supports_force_create=False,
          supports_storage_location=False,
          supports_shielded_instance_initial_state=False):
    """Set Args based on Release Track."""
    # GA Args
    parser.display_info.AddFormat(flags.LIST_FORMAT)

    sources_group = parser.add_mutually_exclusive_group(required=True)
    flags.AddCommonArgs(parser)
    flags.AddCommonSourcesArgs(parser, sources_group)

    Create.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
    Create.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')
    csek_utils.AddCsekKeyArgs(parser, resource_type='image')

    labels_util.AddCreateLabelsFlags(parser)
    flags.MakeForceArg().AddToParser(parser)
    flags.AddCloningImagesArgs(parser, sources_group)
    flags.AddCreatingImageFromSnapshotArgs(parser, sources_group)

    image_utils.AddGuestOsFeaturesArg(parser, release_track)
    kms_resource_args.AddKmsKeyResourceArg(parser, 'image')

    # Alpha and Beta Args
    if supports_force_create:
        # Deprecated as of Aug 2017.
        flags.MakeForceCreateArg().AddToParser(parser)

    if supports_storage_location:
        compute_flags.AddStorageLocationFlag(parser, 'image')

    if supports_shielded_instance_initial_state:
        compute_flags.AddShieldedInstanceInitialStateKeyArg(parser)
示例#5
0
def _CommonArgs(parser):
    """Add parser arguments common to all tracks."""
    SnapshotDisks.disks_arg.AddArgument(parser)

    parser.add_argument('--description',
                        help=('Text to describe the snapshots being created.'))
    parser.add_argument('--snapshot-names',
                        type=arg_parsers.ArgList(min_length=1),
                        metavar='SNAPSHOT_NAME',
                        help="""\
      Names to assign to the created 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-names 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.
      """)
    parser.add_argument(
        '--guest-flush',
        action='store_true',
        default=False,
        help=('Create an application consistent snapshot by informing the OS '
              'to prepare for the snapshot process. Currently only supported '
              'on Windows instances using the Volume Shadow Copy Service '
              '(VSS).'))
    csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)

    base.ASYNC_FLAG.AddToParser(parser)
示例#6
0
def _Args(parser, release_track, supports_kms_keys=False):
    """Set Args based on Release Track."""
    # GA Args
    parser.display_info.AddFormat(flags.LIST_FORMAT)

    sources_group = parser.add_mutually_exclusive_group(required=True)
    flags.AddCommonArgs(parser)
    flags.AddCommonSourcesArgs(parser, sources_group)

    Create.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
    Create.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')
    csek_utils.AddCsekKeyArgs(parser, resource_type='image')

    labels_util.AddCreateLabelsFlags(parser)
    flags.MakeForceArg().AddToParser(parser)
    flags.AddCloningImagesArgs(parser, sources_group)
    flags.AddCreatingImageFromSnapshotArgs(parser, sources_group)

    image_utils.AddGuestOsFeaturesArg(parser, release_track)

    # Alpha and Beta Args
    if release_track in (base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA):
        # Deprecated as of Aug 2017.
        flags.MakeForceCreateArg().AddToParser(parser)

    if supports_kms_keys:
        kms_resource_args.AddKmsKeyResourceArg(parser, 'image')
示例#7
0
def _Args(parser, messages, supports_force_create=False):
    """Set Args based on Release Track."""
    # GA Args
    parser.display_info.AddFormat(flags.LIST_FORMAT)

    sources_group = parser.add_mutually_exclusive_group(required=True)
    flags.AddCommonArgs(parser)
    flags.AddCommonSourcesArgs(parser, sources_group)

    Create.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
    Create.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')
    csek_utils.AddCsekKeyArgs(parser, resource_type='image')

    labels_util.AddCreateLabelsFlags(parser)
    flags.MakeForceArg().AddToParser(parser)
    flags.AddCloningImagesArgs(parser, sources_group)
    flags.AddCreatingImageFromSnapshotArgs(parser, sources_group)

    image_utils.AddGuestOsFeaturesArg(parser, messages)
    kms_resource_args.AddKmsKeyResourceArg(parser, 'image')

    # Alpha and Beta Args
    if supports_force_create:
        # Deprecated as of Aug 2017.
        flags.MakeForceCreateArg().AddToParser(parser)

    parser.add_argument('--storage-location',
                        metavar='LOCATION',
                        help="""\
    Specifies a Cloud Storage location, either regional or multi-regional,
    where image content is to be stored. If not specified, the multi-region
    location closest to the source is chosen automatically.
    """)

    compute_flags.AddShieldedInstanceInitialStateKeyArg(parser)
示例#8
0
def _CommonArgs(parser):
    """Add parser arguments common to all tracks."""
    SnapshotDisks.disks_arg.AddArgument(parser)

    parser.add_argument('--description',
                        help=('Text to describe the snapshots being created.'))
    parser.add_argument('--snapshot-names',
                        type=arg_parsers.ArgList(min_length=1),
                        metavar='SNAPSHOT_NAME',
                        help="""\
      Names to assign to the created snapshots. Without this option, the
      name of each snapshot will be a random 12-character alphanumeric
      string 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-names 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.
      """)
    flags.AddGuestFlushFlag(parser, 'snapshot')
    flags.AddStorageLocationFlag(parser, 'snapshot')
    csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)

    base.ASYNC_FLAG.AddToParser(parser)
示例#9
0
def _CommonArgs(parser):
    """Add parser arguments common to all tracks."""
    SnapshotDisks.disks_arg.AddArgument(parser)

    parser.add_argument('--description',
                        help=('Text to describe the snapshots being created.'))
    parser.add_argument('--snapshot-names',
                        type=arg_parsers.ArgList(min_length=1),
                        metavar='SNAPSHOT_NAME',
                        help="""\
      Names to assign to the created snapshots. Without this option, the
      name of each snapshot will be a random 12-character alphanumeric
      string 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-names 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. The name must match
      the `(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)` regular expression, which
      means it must start with an alphabetic character followed by one or more
      alphanumeric characters or dashes. The name must not exceed 63 characters
      and must not contain special symbols. All characters must be lowercase.
      """)
    flags.AddGuestFlushFlag(parser, 'snapshot')
    flags.AddStorageLocationFlag(parser, 'snapshot')
    csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)

    base.ASYNC_FLAG.AddToParser(parser)
示例#10
0
def _CommonArgs(parser,
                source_snapshot_arg,
                include_physical_block_size_support=False):
    """Add arguments used for parsing in all command tracks."""
    Create.disks_arg.AddArgument(parser, operation_type='create')
    parser.add_argument(
        '--description',
        help='An optional, textual description for the disks being created.')

    parser.add_argument('--size',
                        type=arg_parsers.BinarySize(
                            lower_bound='1GB',
                            suggested_binary_size_scales=[
                                'GB', 'GiB', 'TB', 'TiB', 'PiB', 'PB'
                            ]),
                        help="""\
        Size of the disks. The value must be a whole
        number followed by a size unit of ``GB'' for gigabyte, or ``TB''
        for terabyte. If no size unit is specified, GB is
        assumed. For example, ``10GB'' will produce 10 gigabyte
        disks. Disk size must be a multiple of 1 GB. Limit your boot disk size
        to 2TB to account for MBR partition table limitations. If disk size is
        not specified, the default size of {}GB for standard disks and {}GB for
        pd-ssd disks will be used.
        """.format(constants.DEFAULT_STANDARD_DISK_SIZE_GB,
                   constants.DEFAULT_SSD_DISK_SIZE_GB))

    parser.add_argument('--type',
                        completer=completers.DiskTypesCompleter,
                        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.
      """)

    parser.display_info.AddFormat(
        'table(name, zone.basename(), sizeGb, type.basename(), status)')

    parser.add_argument(
        '--licenses',
        type=arg_parsers.ArgList(),
        metavar='LICENSE',
        help=(
            'A list of URIs to license resources. The provided licenses will '
            'be added onto the created disks to indicate the licensing and '
            'billing policies.'))

    _SourceArgs(parser, source_snapshot_arg)

    csek_utils.AddCsekKeyArgs(parser)
    labels_util.AddCreateLabelsFlags(parser)

    if include_physical_block_size_support:
        parser.add_argument('--physical-block-size',
                            choices=['4096', '16384'],
                            default='4096',
                            help="""\
Physical block size of the persistent disk in bytes.
Valid values are 4096(default) and 16384.
""")
示例#11
0
def _CommonArgs(parser, multiple_network_interface_cards,
                release_track):
  """Register parser args common to all tracks."""
  metadata_utils.AddMetadataArgs(parser)
  instances_flags.AddDiskArgs(parser)
  if release_track in [base.ReleaseTrack.ALPHA]:
    instances_flags.AddCreateDiskArgs(parser)
  instances_flags.AddLocalSsdArgs(parser)
  instances_flags.AddCanIpForwardArgs(parser)
  instances_flags.AddAddressArgs(
      parser, instances=True,
      multiple_network_interface_cards=multiple_network_interface_cards)
  instances_flags.AddMachineTypeArgs(parser)
  instances_flags.AddMaintenancePolicyArgs(parser)
  instances_flags.AddNoRestartOnFailureArgs(parser)
  instances_flags.AddPreemptibleVmArgs(parser)
  instances_flags.AddScopeArgs(parser)
  instances_flags.AddTagsArgs(parser)
  instances_flags.AddCustomMachineTypeArgs(parser)
  instances_flags.AddNetworkArgs(parser)
  instances_flags.AddPrivateNetworkIpArgs(parser)
  instances_flags.AddImageArgs(parser)

  parser.add_argument(
      '--description',
      help='Specifies a textual description of the instances.')

  instances_flags.INSTANCES_ARG.AddArgument(parser)

  csek_utils.AddCsekKeyArgs(parser)
示例#12
0
def _CommonArgs(parser,
                enable_regional=False,
                enable_kms=False,
                enable_snapshots=False,
                deprecate_maintenance_policy=False,
                supports_display_device=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser, enable_regional, enable_kms=enable_kms)
    instances_flags.AddCreateDiskArgs(parser,
                                      enable_kms=enable_kms,
                                      enable_snapshots=enable_snapshots)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(parser, instances=True)
    instances_flags.AddAcceleratorArgs(parser)
    instances_flags.AddMachineTypeArgs(parser)
    instances_flags.AddMaintenancePolicyArgs(
        parser, deprecate=deprecate_maintenance_policy)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(
        parser,
        False,
        extra_scopes_help='However, if neither `--scopes` nor `--no-scopes` are '
        'specified and the project has no default service '
        'account, then the instance will be created with no '
        'scopes.')
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddNetworkArgs(parser)
    instances_flags.AddPrivateNetworkIpArgs(parser)
    instances_flags.AddHostnameArg(parser)
    instances_flags.AddImageArgs(parser, enable_snapshots=enable_snapshots)
    instances_flags.AddDeletionProtectionFlag(parser)
    instances_flags.AddPublicPtrArgs(parser, instance=True)
    instances_flags.AddNetworkTierArgs(parser, instance=True)
    if supports_display_device:
        instances_flags.AddDisplayDeviceArg(parser)

    sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)

    labels_util.AddCreateLabelsFlags(parser)

    parser.add_argument(
        '--description',
        help='Specifies a textual description of the instances.')

    instances_flags.INSTANCES_ARG_FOR_CREATE.AddArgument(
        parser, operation_type='create')

    csek_utils.AddCsekKeyArgs(parser)

    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(
        resource_registry.RESOURCE_REGISTRY['compute.instances'].list_format)
    parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
示例#13
0
def _CommonArgs(parser,
                release_track,
                support_public_dns,
                support_public_ptr,
                support_network_tier,
                enable_regional=False,
                support_local_ssd_size=False,
                enable_kms=False):
  """Register parser args common to all tracks."""
  metadata_utils.AddMetadataArgs(parser)
  instances_flags.AddDiskArgs(parser, enable_regional, enable_kms=enable_kms)
  if release_track in [base.ReleaseTrack.ALPHA]:
    instances_flags.AddCreateDiskArgs(parser, enable_kms=enable_kms)
  if support_local_ssd_size:
    instances_flags.AddLocalSsdArgsWithSize(parser)
  else:
    instances_flags.AddLocalSsdArgs(parser)
  instances_flags.AddCanIpForwardArgs(parser)
  instances_flags.AddAddressArgs(
      parser, instances=True,
      support_network_tier=support_network_tier)
  instances_flags.AddAcceleratorArgs(parser)
  instances_flags.AddMachineTypeArgs(parser)
  deprecate_maintenance_policy = release_track in [base.ReleaseTrack.ALPHA]
  instances_flags.AddMaintenancePolicyArgs(parser, deprecate_maintenance_policy)
  instances_flags.AddNoRestartOnFailureArgs(parser)
  instances_flags.AddPreemptibleVmArgs(parser)
  instances_flags.AddServiceAccountAndScopeArgs(parser, False)
  instances_flags.AddTagsArgs(parser)
  instances_flags.AddCustomMachineTypeArgs(parser)
  instances_flags.AddNetworkArgs(parser)
  instances_flags.AddPrivateNetworkIpArgs(parser)
  instances_flags.AddImageArgs(parser)
  instances_flags.AddDeletionProtectionFlag(parser)
  if support_public_dns:
    instances_flags.AddPublicDnsArgs(parser, instance=True)
  if support_public_ptr:
    instances_flags.AddPublicPtrArgs(parser, instance=True)
  if support_network_tier:
    instances_flags.AddNetworkTierArgs(parser, instance=True)

  labels_util.AddCreateLabelsFlags(parser)
  instances_flags.AddMinCpuPlatformArgs(parser, release_track)

  parser.add_argument(
      '--description',
      help='Specifies a textual description of the instances.')

  instances_flags.INSTANCES_ARG_FOR_CREATE.AddArgument(
      parser, operation_type='create')

  csek_utils.AddCsekKeyArgs(parser)

  base.ASYNC_FLAG.AddToParser(parser)
  parser.display_info.AddFormat(
      resource_registry.RESOURCE_REGISTRY['compute.instances'].list_format)
def _CommonArgs(parser,
                multiple_network_interface_cards,
                release_track,
                support_alias_ip_ranges,
                support_public_dns,
                support_network_tier,
                enable_regional=False,
                support_local_ssd_size=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser, enable_regional)
    if release_track in [base.ReleaseTrack.ALPHA]:
        instances_flags.AddCreateDiskArgs(parser)
    if release_track in [base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA]:
        instances_flags.AddExtendedMachineTypeArgs(parser)
    if support_local_ssd_size:
        instances_flags.AddLocalSsdArgsWithSize(parser)
    else:
        instances_flags.AddLocalSsdArgs(parser)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(
        parser,
        instances=True,
        multiple_network_interface_cards=multiple_network_interface_cards,
        support_alias_ip_ranges=support_alias_ip_ranges,
        support_network_tier=support_network_tier)
    instances_flags.AddAcceleratorArgs(parser)
    instances_flags.AddMachineTypeArgs(parser)
    instances_flags.AddMaintenancePolicyArgs(parser)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(parser, False)
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddNetworkArgs(parser)
    instances_flags.AddPrivateNetworkIpArgs(parser)
    instances_flags.AddImageArgs(parser)
    if support_public_dns:
        instances_flags.AddPublicDnsArgs(parser, instance=True)
    if support_network_tier:
        instances_flags.AddNetworkTierArgs(parser, instance=True)

    labels_util.AddCreateLabelsFlags(parser)

    parser.add_argument(
        '--description',
        help='Specifies a textual description of the instances.')

    instances_flags.INSTANCES_ARG_FOR_CREATE.AddArgument(
        parser, operation_type='create')

    csek_utils.AddCsekKeyArgs(parser)

    parser.display_info.AddFormat(
        resource_registry.RESOURCE_REGISTRY['compute.instances'].list_format)
示例#15
0
 def Args(parser):
     parser.display_info.AddFormat(machine_image_flags.DEFAULT_LIST_FORMAT)
     Create.MACHINE_IMAGE_ARG = machine_image_flags.MakeMachineImageArg()
     Create.MACHINE_IMAGE_ARG.AddArgument(parser, operation_type='create')
     parser.add_argument(
         '--description',
         help='Specifies a textual description of the machine image.')
     csek_utils.AddCsekKeyArgs(parser, resource_type='machine image')
     flags.AddStorageLocationFlag(parser, "machine image's")
     flags.AddGuestFlushFlag(parser, 'machine image')
     flags.AddSourceDiskCsekKeyArg(parser)
     kms_resource_args.AddKmsKeyResourceArg(parser, 'machine image')
     Create.SOURCE_INSTANCE = machine_image_flags.MakeSourceInstanceArg()
     Create.SOURCE_INSTANCE.AddArgument(parser)
示例#16
0
    def Args(cls, parser):
        parser.add_argument(
            '--description',
            help=(
                'An optional, textual description for the image being created.'
            ))

        parser.add_argument('--source-uri',
                            help="""\
        The full Google Cloud Storage URI where the disk image is stored.
        This file must be a gzip-compressed tarball whose name ends in
        ``.tar.gz''.

        This flag is mutually exclusive with ``--source-disk''.
        """)

        flags.SOURCE_DISK_ARG.AddArgument(parser)
        parser.add_argument(
            '--family',
            help=
            ('The family of the image. When creating an instance or disk, '
             'specifying a family will cause the latest non-deprecated image '
             'in the family to be used.'))

        parser.add_argument(
            '--licenses',
            type=arg_parsers.ArgList(),
            help='Comma-separated list of URIs to license resources.')

        if cls._GUEST_OS_FEATURES:
            parser.add_argument(
                '--guest-os-features',
                metavar='GUEST_OS_FEATURE',
                type=arg_parsers.ArgList(element_type=lambda x: x.upper(),
                                         choices=cls._GUEST_OS_FEATURES),
                help=(
                    'One or more features supported by the OS in the image.'))

        if cls._SUPPORT_FORCE_CREATION:
            parser.add_argument(
                '--force-creation',
                action='store_true',
                help=('Force image creation to succeed where it would fail '
                      'otherwise.'))

        flags.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')
        csek_utils.AddCsekKeyArgs(parser, resource_type='image')
示例#17
0
def _Args(parser,
          support_disk_scope=False,
          support_force_attach=False,
          support_boot=False):
    """Add parser arguments to all tracks."""

    flags.INSTANCE_ARG.AddArgument(parser)

    # TODO(b/69955187): Add note about matching with name in order to mount to
    # container.
    parser.add_argument(
        '--device-name',
        help=('An optional name that indicates the disk name the guest '
              'operating system will see. (Note: Device name does not '
              'correspond to mounted volume name). Must match the disk name '
              'if the disk is going to be mounted to a container with '
              '--container-mount-disk (alpha feature).'))

    parser.add_argument('--disk',
                        help='The name of the disk to attach to the instance.',
                        required=True)

    parser.add_argument('--mode',
                        choices=MODE_OPTIONS,
                        default='rw',
                        help='Specifies the mode of the disk.')

    if support_disk_scope:
        flags.AddDiskScopeFlag(parser)

    if support_force_attach:
        parser.add_argument('--force-attach',
                            default=False,
                            action='store_true',
                            help="""\
Attach the disk to the instance even if it is currently attached to another
instance. The attachment will succeed even if detaching from the previous
instance fails at first. The server will continue trying to detach the disk from
the previous instance in the background.""")

    if support_boot:
        parser.add_argument(
            '--boot',
            action='store_true',
            help='Attach the disk to the instance as a boot disk.')

    csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)
示例#18
0
def _CommonArgs(parser, source_snapshot_arg):
    """Add arguments used for parsing in all command tracks."""
    Create.disks_arg.AddArgument(parser, operation_type='create')
    parser.add_argument(
        '--description',
        help='An optional, textual description for the disks being created.')

    parser.add_argument('--size',
                        type=arg_parsers.BinarySize(
                            lower_bound='1GB',
                            suggested_binary_size_scales=[
                                'GB', 'GiB', 'TB', 'TiB', 'PiB', 'PB'
                            ]),
                        help="""\
        Indicates the size of the disks. The value must be a whole
        number followed by a size unit of ``GB'' for gigabyte, or ``TB''
        for terabyte. If no size unit is specified, GB is
        assumed. For example, ``10GB'' will produce 10 gigabyte
        disks. Disk size must be a multiple of 1 GB.
        """)

    parser.add_argument('--type',
                        completer=completers.DiskTypesCompleter,
                        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.
      """)

    parser.display_info.AddFormat(
        'table(name, zone.basename(), sizeGb, type.basename(), status)')

    parser.add_argument(
        '--licenses',
        type=arg_parsers.ArgList(),
        metavar='LICENSE',
        help=(
            'A list of URIs to license resources. The provided licenses will '
            'be added onto the created disks to indicate the licensing and '
            'billing policies.'))

    _SourceArgs(parser, source_snapshot_arg)

    csek_utils.AddCsekKeyArgs(parser)
    labels_util.AddCreateLabelsFlags(parser)
示例#19
0
def _CommonArgs(parser,
                multiple_network_interface_cards,
                release_track,
                support_alias_ip_ranges,
                support_public_dns,
                support_network_tier,
                enable_regional=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser, enable_regional)
    if release_track in [base.ReleaseTrack.ALPHA]:
        instances_flags.AddCreateDiskArgs(parser)
        instances_flags.AddExtendedMachineTypeArgs(parser)
    if release_track in [base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA]:
        instances_flags.AddAcceleratorArgs(parser)
    instances_flags.AddLocalSsdArgs(parser)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(
        parser,
        instances=True,
        multiple_network_interface_cards=multiple_network_interface_cards,
        support_alias_ip_ranges=support_alias_ip_ranges,
        support_network_tier=support_network_tier)
    instances_flags.AddMachineTypeArgs(parser)
    instances_flags.AddMaintenancePolicyArgs(parser)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(parser, False)
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddNetworkArgs(parser)
    instances_flags.AddPrivateNetworkIpArgs(parser)
    instances_flags.AddImageArgs(parser)
    if support_public_dns:
        instances_flags.AddPublicDnsArgs(parser, instance=True)
    if support_network_tier:
        instances_flags.AddNetworkTierArgs(parser, instance=True)

    parser.add_argument(
        '--description',
        help='Specifies a textual description of the instances.')

    instances_flags.INSTANCES_ARG.AddArgument(parser)

    csek_utils.AddCsekKeyArgs(parser)
示例#20
0
def _Args(parser, release_track):
    """Set Args based on Release Track."""
    # GA Args
    parser.display_info.AddFormat(flags.LIST_FORMAT)

    sources_group = parser.add_mutually_exclusive_group(required=True)
    flags.AddCommonArgs(parser)
    flags.AddCommonSourcesArgs(parser, sources_group)

    Create.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
    Create.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')
    csek_utils.AddCsekKeyArgs(parser, resource_type='image')

    labels_util.AddCreateLabelsFlags(parser)

    # Alpha and Beta Args
    if release_track in (base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA):
        flags.AddCloningImagesArgs(parser, sources_group)
        flags.MakeForceCreateArg().AddToParser(parser)
示例#21
0
def _GAArgs(parser):
  """Set Args based on Release Track."""

  # GA specific args
  parser.add_argument('name', help='The name of the snapshot.')
  snap_flags.AddChainArg(parser)
  snap_flags.AddSourceDiskCsekKey(parser)
  flags.AddGuestFlushFlag(parser, 'snapshot', custom_help="""
  Create an application-consistent snapshot by informing the OS
  to prepare for the snapshot process. Currently only supported
  for creating snapshots of disks attached to Windows instances.
  """)
  flags.AddStorageLocationFlag(parser, 'snapshot')
  labels_util.AddCreateLabelsFlags(parser)
  csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)
  base.ASYNC_FLAG.AddToParser(parser)
  parser.add_argument(
      '--description',
      help=('Text to describe the new snapshot.'))
  snap_flags.SOURCE_DISK_ARG.AddArgument(parser)
示例#22
0
def _CommonArgs(parser):
    """Add parser arguments common to all tracks."""

    flags.INSTANCE_ARG.AddArgument(parser)

    parser.add_argument(
        '--device-name',
        help=('An optional name that indicates the disk name the guest '
              'operating system will see. (Note: Device name does not '
              'correspond to mounted volume name)'))

    parser.add_argument('--disk',
                        help='The name of the disk to attach to the instance.',
                        required=True)

    parser.add_argument('--mode',
                        choices=MODE_OPTIONS,
                        default='rw',
                        help='Specifies the mode of the disk.')

    csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)
示例#23
0
def _CommonArgs(parser, snapshot_chain_enabled=False):
    """Add parser arguments common to all tracks."""
    SnapshotDisks.disks_arg.AddArgument(parser)

    parser.add_argument('--description',
                        help=('Text to describe the snapshots being created.'))
    parser.add_argument('--snapshot-names',
                        type=arg_parsers.ArgList(min_length=1),
                        metavar='SNAPSHOT_NAME',
                        help="""\
      Names to assign to the created snapshots. Without this option, the
      name of each snapshot will be a random 12-character alphanumeric
      string 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-names 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. The name must match
      the `(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)` regular expression, which
      means it must start with an alphabetic character followed by one or more
      alphanumeric characters or dashes. The name must not exceed 63 characters
      and must not contain special symbols. All characters must be lowercase.
      """)
    if snapshot_chain_enabled:
        parser.add_argument(
            '--chain-name',
            help=
            ("""Creates the new snapshot in the snapshot chain labeled with the specified name.
            The chain name must be 1-63 characters long and comply with RFC1035.
            Use this flag only if you are an advanced service owner who needs
            to create separate snapshot chains, for example, for chargeback tracking.
            When you describe your snapshot resource, this field is visible only
            if it has a non-empty value."""))
    flags.AddGuestFlushFlag(parser, 'snapshot')
    flags.AddStorageLocationFlag(parser, 'snapshot')
    csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)

    base.ASYNC_FLAG.AddToParser(parser)
示例#24
0
文件: create.py 项目: bopopescu/UCSC
    def Args(parser):
        parser.add_argument(
            '--description',
            help=(
                'An optional, textual description for the image being created.'
            ))

        source_uri = parser.add_argument(
            '--source-uri',
            help=('The full Google Cloud Storage URI where the disk image is '
                  'stored.'))
        source_uri.detailed_help = """\
        The full Google Cloud Storage URI where the disk image is stored.
        This file must be a gzip-compressed tarball whose name ends in
        ``.tar.gz''.

        This flag is mutually exclusive with ``--source-disk''.
        """

        flags.SOURCE_DISK_ARG.AddArgument(parser)
        parser.add_argument(
            '--family',
            help=
            ('The family of the image. When creating an instance or disk, '
             'specifying a family will cause the latest non-deprecated image '
             'in the family to be used.'))

        parser.add_argument(
            '--licenses',
            type=arg_parsers.ArgList(),
            help='Comma-separated list of URIs to license resources.')

        parser.add_argument('name',
                            metavar='NAME',
                            help='The name of the image to create.')

        csek_utils.AddCsekKeyArgs(parser, resource_type='image')
示例#25
0
 def Args(parser):
     flags.INSTANCES_ARG.AddArgument(parser)
     csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)
     base.ASYNC_FLAG.AddToParser(parser)
示例#26
0
 def Args(parser):
     _CommonArgs(parser)
     csek_utils.AddCsekKeyArgs(parser)
     _SourceArgs(parser, image_family=True)
示例#27
0
def _CommonArgs(
        parser,
        # TODO(b/80138906): Release track should not be passed around.
        release_track,
        support_public_dns,
        support_network_tier,
        enable_regional=False,
        support_local_ssd_size=False,
        enable_kms=False,
        support_sole_tenancy=False,
        supports_resource_policies=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser, enable_regional, enable_kms=enable_kms)
    instances_flags.AddCreateDiskArgs(parser, enable_kms=enable_kms)
    if support_local_ssd_size:
        instances_flags.AddLocalSsdArgsWithSize(parser)
    else:
        instances_flags.AddLocalSsdArgs(parser)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(parser,
                                   instances=True,
                                   support_network_tier=support_network_tier)
    instances_flags.AddAcceleratorArgs(parser)
    instances_flags.AddMachineTypeArgs(parser)
    deprecate_maintenance_policy = release_track in [base.ReleaseTrack.ALPHA]
    instances_flags.AddMaintenancePolicyArgs(parser,
                                             deprecate_maintenance_policy)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(
        parser,
        False,
        extra_scopes_help='However, if neither `--scopes` nor `--no-scopes` are '
        'specified and the project has no default service '
        'account, then the instance will be created with no '
        'scopes.')
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddNetworkArgs(parser)
    instances_flags.AddPrivateNetworkIpArgs(parser)
    instances_flags.AddImageArgs(parser)
    instances_flags.AddDeletionProtectionFlag(parser)
    instances_flags.AddPublicPtrArgs(parser, instance=True)
    if support_public_dns:
        instances_flags.AddPublicDnsArgs(parser, instance=True)
    if support_network_tier:
        instances_flags.AddNetworkTierArgs(parser, instance=True)
    if support_sole_tenancy:
        sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)
    if supports_resource_policies:
        maintenance_flags.AddResourcePoliciesArgs(parser, 'added to',
                                                  'instance')

    labels_util.AddCreateLabelsFlags(parser)
    instances_flags.AddMinCpuPlatformArgs(parser, release_track)

    parser.add_argument(
        '--description',
        help='Specifies a textual description of the instances.')

    instances_flags.INSTANCES_ARG_FOR_CREATE.AddArgument(
        parser, operation_type='create')

    csek_utils.AddCsekKeyArgs(parser)

    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(
        resource_registry.RESOURCE_REGISTRY['compute.instances'].list_format)
    parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
示例#28
0
文件: create.py 项目: linsole/CS61A
def _CommonArgs(parser,
                enable_regional=False,
                enable_kms=False,
                deprecate_maintenance_policy=False,
                enable_resource_policy=False,
                supports_min_node_cpus=False,
                supports_location_hint=False,
                snapshot_csek=False,
                image_csek=False):
  """Register parser args common to all tracks."""
  metadata_utils.AddMetadataArgs(parser)
  instances_flags.AddDiskArgs(parser, enable_regional, enable_kms=enable_kms)
  instances_flags.AddCreateDiskArgs(parser, enable_kms=enable_kms,
                                    enable_snapshots=True,
                                    resource_policy=enable_resource_policy,
                                    source_snapshot_csek=snapshot_csek,
                                    image_csek=image_csek)
  instances_flags.AddCanIpForwardArgs(parser)
  instances_flags.AddAddressArgs(parser, instances=True)
  instances_flags.AddAcceleratorArgs(parser)
  instances_flags.AddMachineTypeArgs(parser)
  instances_flags.AddMaintenancePolicyArgs(
      parser, deprecate=deprecate_maintenance_policy)
  instances_flags.AddNoRestartOnFailureArgs(parser)
  instances_flags.AddPreemptibleVmArgs(parser)
  instances_flags.AddServiceAccountAndScopeArgs(
      parser, False,
      extra_scopes_help='However, if neither `--scopes` nor `--no-scopes` are '
                        'specified and the project has no default service '
                        'account, then the instance will be created with no '
                        'scopes. Note that the level of access that a service '
                        'account has is determined by a combination of access '
                        'scopes and IAM roles so you must configure both '
                        'access scopes and IAM roles for the service account '
                        'to work properly.')
  instances_flags.AddTagsArgs(parser)
  instances_flags.AddCustomMachineTypeArgs(parser)
  instances_flags.AddNetworkArgs(parser)
  instances_flags.AddPrivateNetworkIpArgs(parser)
  instances_flags.AddHostnameArg(parser)
  instances_flags.AddImageArgs(parser, enable_snapshots=True)
  instances_flags.AddDeletionProtectionFlag(parser)
  instances_flags.AddPublicPtrArgs(parser, instance=True)
  instances_flags.AddNetworkTierArgs(parser, instance=True)
  instances_flags.AddShieldedInstanceConfigArgs(parser)
  instances_flags.AddDisplayDeviceArg(parser)

  instances_flags.AddReservationAffinityGroup(
      parser,
      group_text='Specifies the reservation for the instance.',
      affinity_text='The type of reservation for the instance.')

  sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)

  if supports_min_node_cpus:
    sole_tenancy_flags.AddMinNodeCpusArg(parser)

  if supports_location_hint:
    instances_flags.AddLocationHintArg(parser)

  labels_util.AddCreateLabelsFlags(parser)

  parser.add_argument(
      '--description',
      help='Specifies a textual description of the instances.')

  instances_flags.INSTANCES_ARG_FOR_CREATE.AddArgument(
      parser, operation_type='create')

  csek_utils.AddCsekKeyArgs(parser)

  base.ASYNC_FLAG.AddToParser(parser)
  parser.display_info.AddFormat(
      resource_registry.RESOURCE_REGISTRY['compute.instances'].list_format)
  parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
示例#29
0
 def Args(parser):
   _CommonArgs(parser)
   csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)
示例#30
0
def _CommonArgs(parser,
                include_physical_block_size_support=False,
                vss_erase_enabled=False,
                source_instant_snapshot_enabled=False,
                support_pd_interface=False,
                support_provisioned_iops=False):
    """Add arguments used for parsing in all command tracks."""
    Create.disks_arg.AddArgument(parser, operation_type='create')
    parser.add_argument(
        '--description',
        help='An optional, textual description for the disks being created.')

    # TODO(b/158105562) Add help text for pd-extreme before GA.
    parser.add_argument(
        '--size',
        type=arg_parsers.BinarySize(lower_bound='10GB',
                                    suggested_binary_size_scales=[
                                        'GB', 'GiB', 'TB', 'TiB', 'PiB', 'PB'
                                    ]),
        help="""\
        Size of the disks. The value must be a whole
        number followed by a size unit of ``GB'' for gigabyte, or ``TB''
        for terabyte. If no size unit is specified, GB is
        assumed. For example, ``10GB'' will produce 10 gigabyte
        disks. Disk size must be a multiple of 1 GB. Limit your boot disk size
        to 2TB to account for MBR partition table limitations. If disk size is
        not specified, the default size of {}GB for pd-standard disks, {}GB for
        pd-balanced disks, and {}GB for pd-ssd disks will be used. For details
        about disk size limits, refer to:
        https://cloud.google.com/compute/docs/disks
        """.format(
            constants.DEFAULT_DISK_SIZE_GB_MAP[
                constants.DISK_TYPE_PD_STANDARD],
            constants.DEFAULT_DISK_SIZE_GB_MAP[
                constants.DISK_TYPE_PD_BALANCED],
            constants.DEFAULT_DISK_SIZE_GB_MAP[constants.DISK_TYPE_PD_SSD]))

    parser.add_argument('--type',
                        completer=completers.DiskTypesCompleter,
                        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.
      """)

    if support_pd_interface:
        parser.add_argument('--interface',
                            help="""\
        Specifies the disk interface to use for attaching this disk. Valid values
        are `SCSI` and `NVME`. The default is `SCSI`.
        """)

    parser.display_info.AddFormat(
        'table(name, zone.basename(), sizeGb, type.basename(), status)')

    parser.add_argument(
        '--licenses',
        type=arg_parsers.ArgList(),
        metavar='LICENSE',
        help=(
            'A list of URIs to license resources. The provided licenses will '
            'be added onto the created disks to indicate the licensing and '
            'billing policies.'))

    _SourceArgs(parser, source_instant_snapshot_enabled)

    if support_provisioned_iops:
        parser.add_argument(
            '--provisioned-iops',
            type=arg_parsers.BoundedInt(constants.MIN_PROVISIONED_IOPS,
                                        constants.MAX_PROVISIONED_IOPS),
            help=
            ('Provisioned IOPS of pd-extreme disk to create. If specified, '
             'the value must be in the range between {min} and {max}. If not '
             'specified, the default value is {default}.').format(
                 min=constants.MIN_PROVISIONED_IOPS,
                 max=constants.MAX_PROVISIONED_IOPS,
                 default=constants.DEFAULT_PROVISIONED_IOPS))

    csek_utils.AddCsekKeyArgs(parser)
    labels_util.AddCreateLabelsFlags(parser)

    if include_physical_block_size_support:
        parser.add_argument('--physical-block-size',
                            choices=['4096', '16384'],
                            default='4096',
                            help="""\
Physical block size of the persistent disk in bytes.
Valid values are 4096(default) and 16384.
""")
    if vss_erase_enabled:
        flags.AddEraseVssSignature(parser, resource='a source snapshot')

    resource_flags.AddResourcePoliciesArgs(parser, 'added to', 'disk')