示例#1
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)
示例#2
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)
示例#3
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)
示例#4
0
  def Args(cls, parser):
    parser.display_info.AddFormat(machine_image_flags.DEFAULT_LIST_FORMAT)
    Import.MACHINE_IMAGE_ARG = machine_image_flags.MakeMachineImageArg()
    Import.MACHINE_IMAGE_ARG.AddArgument(parser, operation_type='import')
    parser.add_argument(
        '--description',
        help='Specifies a text description of the machine image.')
    flags.AddStorageLocationFlag(parser, "machine image's")
    flags.AddGuestFlushFlag(parser, 'machine image')

    machine_image_flags.AddNoRestartOnFailureArgs(parser)
    machine_image_flags.AddTagsArgs(parser)
    machine_image_flags.AddCanIpForwardArgs(parser)
    machine_image_flags.AddNetworkArgs(parser)
    machine_image_flags.AddNetworkTierArgs(parser)

    instances_flags.AddMachineTypeArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    labels_util.AddCreateLabelsFlags(parser)
    daisy_utils.AddCommonDaisyArgs(
        parser, operation='an import')
    daisy_utils.AddExtraCommonDaisyArgs(parser)
    daisy_utils.AddOVFSourceUriArg(parser)
    parser.add_argument(
        '--os',
        required=False,
        choices=sorted(os_choices.OS_CHOICES_INSTANCE_IMPORT_BETA),
        help='Specifies the OS of the machine image being imported.')
    flags.AddZoneFlag(
        parser,
        'machine image',
        'import',
        explanation='The zone in which to perform the import of the machine image. '
        + flags.ZONE_PROPERTY_EXPLANATION)
    daisy_utils.AddGuestEnvironmentArg(parser, 'machine image')
    parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
    daisy_utils.AddNoAddressArg(
        parser,
        'machine image import',
        docs_url='https://cloud.google.com/nat/docs/gce-example#create-nat '
        + 'and https://cloud.google.com/vpc/docs/private-access-options#pga'
    )
示例#5
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)
示例#6
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)
    def Args(cls, parser):
        compute_holder = cls._GetComputeApiHolder(no_http=True)
        messages = compute_holder.client.messages

        parser.display_info.AddFormat(machine_image_flags.DEFAULT_LIST_FORMAT)
        Import.MACHINE_IMAGE_ARG = machine_image_flags.MakeMachineImageArg()
        Import.MACHINE_IMAGE_ARG.AddArgument(parser, operation_type='import')
        parser.add_argument(
            '--description',
            help='Specifies a text description of the machine image.')
        flags.AddStorageLocationFlag(parser, "machine image's")
        flags.AddGuestFlushFlag(parser, 'machine image')

        machine_image_flags.AddNoRestartOnFailureArgs(parser)
        machine_image_flags.AddTagsArgs(parser)
        machine_image_flags.AddCanIpForwardArgs(parser)
        machine_image_flags.AddNetworkArgs(parser)
        machine_image_flags.AddNetworkTierArgs(parser)

        instances_flags.AddMachineTypeArgs(parser)
        instances_flags.AddCustomMachineTypeArgs(parser)
        labels_util.AddCreateLabelsFlags(parser)
        daisy_utils.AddCommonDaisyArgs(parser, operation='an import')
        daisy_utils.AddOVFSourceUriArg(parser)

        if cls.ReleaseTrack() != base.ReleaseTrack.GA:
            image_utils.AddGuestOsFeaturesArgForImport(parser, messages)

        parser.add_argument(
            '--os',
            required=False,
            choices=sorted(os_choices.OS_CHOICES_INSTANCE_IMPORT_BETA),
            help='Specifies the OS of the machine image being imported.')
        daisy_utils.AddByolArg(parser)
        flags.AddZoneFlag(
            parser,
            'machine image',
            'import',
            explanation=
            'The zone in which to perform the import of the machine image. ' +
            flags.ZONE_PROPERTY_EXPLANATION)
        daisy_utils.AddGuestEnvironmentArg(parser, 'machine image')
        parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
        daisy_utils.AddNoAddressArg(
            parser,
            'machine image import',
            docs_url=
            ('https://cloud.google.com/nat/docs/gce-example#create-nat '
             'and https://cloud.google.com/vpc/docs/private-access-options#pga'
             ))
        daisy_utils.AddComputeServiceAccountArg(
            parser, 'machine image import',
            daisy_utils.IMPORT_ROLES_FOR_COMPUTE_SERVICE_ACCOUNT)
        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 machine image is imported 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.'),
            operation='Import',
            resource='machine image')