Ejemplo n.º 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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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.
      """)
    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).'))
    flags.AddStorageLocationFlag(parser, 'snapshot')
    csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)

    base.ASYNC_FLAG.AddToParser(parser)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
def AddBackupScheduleArgs(parser):
    """Adds flags specific to backup schedule resource policies."""
    parser.add_argument(
        '--max-retention-days',
        required=True,
        type=arg_parsers.BoundedInt(lower_bound=1),
        help='Maximum number of days snapshot can be retained.')
    snapshot_properties_group = parser.add_group('Snapshot properties')
    labels_util.GetCreateLabelsFlag(
        extra_message='These will be added to the disk snapshots on creation.',
        labels_name='snapshot-labels').AddToParser(snapshot_properties_group)
    snapshot_properties_group.add_argument(
        '--guest-flush',
        action='store_true',
        help='Create an application consistent snapshot by informing the OS to '
        'prepare for the snapshot process.')
    compute_flags.AddStorageLocationFlag(snapshot_properties_group, 'snapshot')
Ejemplo n.º 7
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'
    )
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
 def Args(parser):
     SnapshotDisks.disks_arg = disks_flags.MakeDiskArgZonalOrRegional(
         plural=True)
     flags.AddStorageLocationFlag(parser, 'snapshot')
     _CommonArgs(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')
Ejemplo n.º 12
0
 def Args(parser):
     SnapshotDisks.disks_arg = disks_flags.MakeDiskArg(plural=True)
     labels_util.AddCreateLabelsFlags(parser)
     flags.AddStorageLocationFlag(parser, 'snapshot')
     _CommonArgs(parser)