Exemple #1
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)
Exemple #2
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)
Exemple #3
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')
Exemple #4
0
  def Args(parser):
    Import.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
    Import.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')

    parser.add_argument(
        '--source-uri',
        required=True,
        help=('The Google Cloud Storage URI of the '
              'virtual disk file to import.'),
    )
    daisy_utils.AddCommonDaisyArgs(parser)
Exemple #5
0
 def Args(parser):
     DescribeFromFamily.DiskImageArg = flags.MakeDiskImageArg()
     DescribeFromFamily.DiskImageArg.AddArgument(parser,
                                                 operation_type='describe')
     # Do not use compute_flags.AddZoneFlag() because there should be no
     # interaction with the compute/zone property.
     parser.add_argument(
         '--zone',
         completer=completers.ZonesCompleter,
         help=
         ('Zone to query. Returns the latest image available in the image '
          'family for the specified zone. If not specified, returns the '
          'latest globally available image.'))
Exemple #6
0
 def Args(parser):
     lister.AddBaseListerArgs(parser)
     parser.display_info.AddFormat("""\
     table(
       resourceUrl.name():label=IMAGE_ID,
       noteName:label=NOTE,
       vulnerabilityDetails.severity,
       vulnerabilityDetails.cvssScore,
       vulnerabilityDetails.packageIssue.affectedLocation.package.join(','):label=PACKAGES
     )""")
     List._image_arg = image_flags.MakeDiskImageArg(required=False,
                                                    name='--image')
     List._image_arg.AddArgument(parser, operation_type='create')
Exemple #7
0
def _Args(cls, parser, patch_enable=False):
  """Set Args based on Release Track."""
  cls.DISK_IMAGE_ARG = images_flags.MakeDiskImageArg(plural=False)
  cls.DISK_IMAGE_ARG.AddArgument(parser, operation_type='update')
  labels_util.AddUpdateLabelsFlags(parser)

  if patch_enable:
    parser.add_argument(
        '--description',
        help=('An optional text description for the image.'))

    parser.add_argument(
        '--family',
        help=('Name of the image family to use. If an image family is '
              'specified when you create an instance or disk, the latest '
              'non-deprecated image in the family is used.')
    )
def _Args(cls, parser, patch_enable=False):
  """Set Args based on Release Track."""
  cls.DISK_IMAGE_ARG = images_flags.MakeDiskImageArg(plural=False)
  cls.DISK_IMAGE_ARG.AddArgument(parser, operation_type='update')
  labels_util.AddUpdateLabelsFlags(parser)

  if patch_enable:
    parser.add_argument(
        '--description',
        help=('An optional text description for the image being created.'))

    parser.add_argument(
        '--family',
        help=('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.')
    )
    def Args(cls, parser):
        Import.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
        Import.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')

        flags.compute_flags.AddZoneFlag(
            parser,
            'image',
            'import',
            explanation=
            'The zone in which to do the work of importing the image.')

        source = parser.add_mutually_exclusive_group(required=True)
        source.add_argument(
            '--source-file',
            help=(
                """A local file, or the Google Cloud Storage URI of the virtual
              disk file to import. For example: ``gs://my-bucket/my-image.vmdk''
              or ``./my-local-image.vmdk''"""),
        )
        flags.SOURCE_IMAGE_ARG.AddArgument(source, operation_type='import')

        workflow = parser.add_mutually_exclusive_group(required=True)
        workflow.add_argument(
            '--os',
            choices=sorted(cls._OS_CHOICES),
            help='Specifies the OS of the image being imported.')
        workflow.add_argument(
            '--data-disk',
            help=(
                'Specifies that the disk has no bootable OS installed on it. '
                'Imports the disk without making it bootable or installing '
                'Google tools on it.'),
            action='store_true')
        workflow.add_argument('--custom-workflow',
                              help=("""\
              Specifies a custom workflow to use for image translation.
              Workflow should be relative to the image_import directory here:
              []({0}). For example: ``{1}''""".format(
                                  _WORKFLOWS_URL,
                                  os_choices.OS_CHOICES_MAP[sorted(
                                      cls._OS_CHOICES)[0]])),
                              hidden=True)

        daisy_utils.AddCommonDaisyArgs(parser)
        parser.display_info.AddCacheUpdater(flags.ImagesCompleter)
Exemple #10
0
 def Args(parser):
     lister.AddBaseListerArgs(parser)
     parser.display_info.AddFormat("""\
     table(
       name,
       noteName.basename():label=NOTE,
       vulnerabilityDetails.severity,
       vulnerabilityDetails.cvssScore,
       vulnerabilityDetails.packageIssue.affectedLocation.package.join(','):label=PACKAGES
     )""")
     List._image_arg = image_flags.MakeDiskImageArg(required=False,
                                                    name='--image')
     List._image_arg.AddArgument(parser, operation_type='create')
     # This allows the occurrence if ANY of its PackageIssues have
     # fixedLocation.version.kind != MAXIMUM.
     # TODO(b/72375279): Do server-side
     parser.display_info.AddFilter(
         'vulnerabilityDetails.packageIssue.fixedLocation.version.kind != '
         '"MAXIMUM"')
Exemple #11
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)
Exemple #12
0
    def Args(cls, parser):
        parser.display_info.AddFormat(flags.LIST_FORMAT)
        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.'))

        Create.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
        Create.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')
        csek_utils.AddCsekKeyArgs(parser, resource_type='image')
Exemple #13
0
  def Args(parser):
    Export.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
    Export.DISK_IMAGE_ARG.AddArgument(parser, operation_type='export')

    parser.add_argument(
        '--destination-uri',
        required=True,
        help=('The Google Cloud Storage URI destination for '
              'the exported virtual disk file.'),
    )

    # Export format can take more values than what we list here in the help.
    # However, we don't want to suggest formats that will likely never be used,
    # so we list common ones here, but don't prevent others from being used.
    parser.add_argument(
        '--export-format',
        help=('Specify the format to export to, such as '
              '`vmdk`, `vhdx`, `vpc`, or `qcow2`.'),
    )
    daisy_utils.AddCommonDaisyArgs(parser)
    parser.display_info.AddCacheUpdater(flags.ImagesCompleter)
Exemple #14
0
    def Args(parser):
        Import.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
        Import.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')

        source = parser.add_mutually_exclusive_group(required=True)
        source.add_argument(
            '--source-file',
            help=(
                """A local file, or the Google Cloud Storage URI of the virtual
              disk file to import. For example: ``gs://my-bucket/my-image.vmdk''
              or ``./my-local-image.vmdk''"""),
        )
        flags.SOURCE_IMAGE_ARG.AddArgument(source, operation_type='translate')

        workflow = parser.add_mutually_exclusive_group(required=True)
        workflow.add_argument(
            '--os',
            choices=sorted(_OS_CHOICES.keys()),
            help='Specifies the OS of the image being translated.')
        workflow.add_argument(
            '--translate',
            default=True,
            action='store_true',
            help=
            ('Import the disk without making it bootable or installing Google '
             'tools on it.'))
        workflow.add_argument('--custom-workflow',
                              help=("""\
              Specifies a custom workflow to use for the image translate.
              Workflow should be relative to the image_import directory here:
              []({0}). For example: ``{1}''""".format(
                                  _WORKFLOWS_URL,
                                  _OS_CHOICES[sorted(_OS_CHOICES.keys())[0]])),
                              hidden=True)

        daisy_utils.AddCommonDaisyArgs(parser)
        parser.display_info.AddCacheUpdater(flags.ImagesCompleter)
 def Args(parser):
     Describe.DiskImageArg = flags.MakeDiskImageArg()
     Describe.DiskImageArg.AddArgument(parser, operation_type='describe')
Exemple #16
0
    def Args(parser):
        DeprecateImages.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
        DeprecateImages.DISK_IMAGE_ARG.AddArgument(parser)
        flags.REPLACEMENT_DISK_IMAGE_ARG.AddArgument(parser)

        deprecation_statuses = {
            'ACTIVE':
            'The image is currently supported.',
            'DELETED':
            ('New uses result in an error. Setting this state will not '
             'automatically delete the image. You must still make a request to '
             'delete the image to remove it from the image list.'),
            'DEPRECATED':
            ('Operations which create a new *DEPRECATED* resource return '
             'successfully, but with a warning indicating that the image is '
             'deprecated and recommending its replacement.'),
            'OBSOLETE':
            'New uses result in an error.',
        }

        parser.add_argument('--state',
                            choices=deprecation_statuses,
                            default='ACTIVE',
                            type=lambda x: x.upper(),
                            required=True,
                            help='The deprecation state to set on the image.')

        deprecate_group = parser.add_mutually_exclusive_group()

        deprecate_group.add_argument('--deprecate-on',
                                     help="""\
        Specifies time (in the same format as *--delete-on*) when this image
        will be marked as DEPRECATED. State will not be changed - it has only
        informational purpose.
        This flag is mutually exclusive with *--deprecate-in*.
        """)

        deprecate_group.add_argument('--deprecate-in',
                                     type=arg_parsers.Duration(),
                                     help="""\
        Specifies time (in the same format as *--delete-in*) until the image
        will be marked DEPRECATED. State will not be changed - it is only for
        informational purposes.
        This flag is mutually exclusive with *--deprecate-on*.
       """)

        delete_group = parser.add_mutually_exclusive_group()

        delete_group.add_argument('--delete-on',
                                  help="""\
        Similar to *--delete-in*, but specifies an absolute time when the image
        will be marked as DELETED. Note: The image will not actually be
        deleted - this field is for informational purposes (see the description
        of --delete-in for more details). The date and time specified must be
        valid RFC 3339 full-date or date-time. For times in UTC, this looks
        like ``YYYY-MM-DDTHH:MM:SSZ''. For example: 2020-01-02T00:00:00Z for
        midnight on January 2, 2020 in UTC.
        This flag is mutually exclusive with *--delete-in*.
        """)

        delete_group.add_argument('--delete-in',
                                  type=arg_parsers.Duration(),
                                  help="""\
       Specifies the amount of time until the image will be marked as DELETED.
       Note: The image will not actually be deleted - this field is only for
       informational purposes (see below). For instance, specifying ``30d'' will
       mark the image as DELETED in 30 days from the current system time.
       See $ gcloud topic datetimes for information on duration formats.

       Note that the image will not be deleted automatically. The image will
       only be marked as deleted. An explicit request to delete the image must
       be made in order to remove it from the image list.
       This flag is mutually exclusive with *--delete-on*.
       """)

        obsolete_group = parser.add_mutually_exclusive_group()

        obsolete_group.add_argument('--obsolete-on',
                                    help="""\
       Specifies time (in the same format as *--delete-on*) when this image will
       be marked as OBSOLETE. State will not be changed - it has only
       informational purpose.
       This flag is mutually exclusive with *--obsolete-in*.
       """)

        obsolete_group.add_argument('--obsolete-in',
                                    type=arg_parsers.Duration(),
                                    help="""\
       Specifies time (in the same format as *--delete-in*) until the image
       will be marked OBSOLETE. State will not be changed - it is only for
       informational purposes.
       This flag is mutually exclusive with *--obsolete-on*.
       """)
Exemple #17
0
    def Args(parser):
        DeprecateImages.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
        DeprecateImages.DISK_IMAGE_ARG.AddArgument(parser)
        flags.REPLACEMENT_DISK_IMAGE_ARG.AddArgument(parser)

        deprecation_statuses = {
            'ACTIVE':
            'The image is currently supported.',
            'DELETED':
            ('New uses result in an error. Setting this state will not '
             'automatically delete the image. You must still make a request to '
             'delete the image to remove it from the image list.'),
            'DEPRECATED':
            ('Operations which create a new *DEPRECATED* resource return '
             'successfully, but with a warning indicating that the image is '
             'deprecated and recommending its replacement.'),
            'OBSOLETE':
            'New uses result in an error.',
        }

        parser.add_argument('--state',
                            choices=deprecation_statuses,
                            default='ACTIVE',
                            type=lambda x: x.upper(),
                            required=True,
                            help='The deprecation state to set on the image.')

        deprecate_group = parser.add_mutually_exclusive_group()

        deprecate_group.add_argument('--deprecate-on',
                                     help="""\
        Specifies a date when the image should be marked as DEPRECATED.

        Note: This is only informational and the image will not be deprecated unless you manually deprecate it.

        This flag is mutually exclusive with *--deprecate-in*.

        The date and time specified must be valid RFC 3339 full-date or date-time.
        For times in UTC, this looks like ``YYYY-MM-DDTHH:MM:SSZ''.
        For example: 2020-01-02T00:00:00Z for midnight on January 2, 2020 in UTC.
        """)

        deprecate_group.add_argument('--deprecate-in',
                                     type=arg_parsers.Duration(),
                                     help="""\
        Specifies a time duration in which the image should be marked as ``DEPRECATED''.

        Note: This is only informational and the image will not be deprecated unless you manually deprecate it.

        This flag is mutually exclusive with *--deprecate-on*.

        For example, specifying ``30d'' sets the planned ``DEPRECATED'' date to 30 days from the current system time,
        but does not deprecate the image. You must manually deprecate the image in 30 days.
        See $ gcloud topic datetimes for information on duration formats.

       """)

        delete_group = parser.add_mutually_exclusive_group()

        delete_group.add_argument('--delete-on',
                                  help="""\
        Specifies a date when the image should be marked as ``DELETED''.

        Note: This is only informational and the image will not be deleted unless you manually delete it.

        This flag is mutually exclusive with *--delete-in*.

        The date and time specified must be valid RFC 3339 full-date or date-time.
        For times in UTC, this looks like ``YYYY-MM-DDTHH:MM:SSZ''.
        For example: 2020-01-02T00:00:00Z for midnight on January 2, 2020 in UTC.

        """)

        delete_group.add_argument('--delete-in',
                                  type=arg_parsers.Duration(),
                                  help="""\
        Specifies a time duration in which the image should be marked as ``DELETED''.

        Note: This is only informational and the image will not be deleted unless you manually delete it.

        For example, specifying ``30d'' sets the planned ``DELETED'' time to 30 days from the current system time,
        but does not delete the image. You must manually delete the image in 30 days.
        See $ gcloud topic datetimes for information on duration formats.

        This flag is mutually exclusive with *--delete-on*.
       """)

        obsolete_group = parser.add_mutually_exclusive_group()

        obsolete_group.add_argument('--obsolete-on',
                                    help="""\
        Specifies a date when the image should be marked as ``OBSOLETE''.

        Note: This is only informational and the image will not be obsoleted unless you manually obsolete it.

        This flag is mutually exclusive with *--obsolete-in*.

        The date and time specified must be valid RFC 3339 full-date or date-time.
        For times in UTC, this looks like ``YYYY-MM-DDTHH:MM:SSZ''.
        For example: 2020-01-02T00:00:00Z for midnight on January 2, 2020 in UTC.
       """)

        obsolete_group.add_argument('--obsolete-in',
                                    type=arg_parsers.Duration(),
                                    help="""\
        Specifies a time duration in which the image should be marked as ``OBSOLETE''.

        Note: This is only informational and the image will not be obsoleted unless you manually obsolete it.

        This flag is mutually exclusive with *--obsolete-on*.

        For example, specifying ``30d'' sets the planned ``OBSOLETE'' time to 30 days from the current system time,
        but does not obsolete the image. You must manually obsolete the image in 30 days.
        See $ gcloud topic datetimes for information on duration formats.
        """)
Exemple #18
0
 def Args(parser):
     SetIamPolicy.disk_image_arg = flags.MakeDiskImageArg(plural=False)
     SetIamPolicy.disk_image_arg.AddArgument(
         parser, operation_type='set the IAM policy of')
     compute_flags.AddPolicyFileFlag(parser)
Exemple #19
0
 def Args(cls, parser):
   cls.DISK_IMAGE_ARG = images_flags.MakeDiskImageArg(plural=False)
   cls.DISK_IMAGE_ARG.AddArgument(parser, operation_type='update')
   labels_util.AddUpdateLabelsFlags(parser)
 def Args(parser):
     Delete.DiskImageArg = flags.MakeDiskImageArg(plural=True)
     Delete.DiskImageArg.AddArgument(parser, operation_type='delete')
     parser.display_info.AddCacheUpdater(flags.ImagesCompleter)
Exemple #21
0
    def Args(cls, parser):
        Import.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
        Import.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')

        flags.compute_flags.AddZoneFlag(
            parser,
            'image',
            'import',
            explanation=
            'The zone in which to do the work of importing the image.')

        if cls.ReleaseTrack() == base.ReleaseTrack.GA:
            source = parser.add_mutually_exclusive_group(required=True)
            source.add_argument(
                '--source-file',
                help=("""A local file, or the Cloud Storage URI of the virtual
              disk file to import. For example: ``gs://my-bucket/my-image.vmdk''
              or ``./my-local-image.vmdk''"""),
            )
            flags.SOURCE_IMAGE_ARG.AddArgument(source, operation_type='import')
        else:
            source = parser.add_mutually_exclusive_group(required=True)

            import_from_local_or_gcs = source.add_mutually_exclusive_group(
                help=
                'Image import from local file, Cloud Storage or Compute Engine image.'
            )
            import_from_local_or_gcs.add_argument(
                '--source-file',
                help=("""A local file, or the Cloud Storage URI of the virtual
                disk file to import. For example: ``gs://my-bucket/my-image.vmdk''
                or ``./my-local-image.vmdk''"""),
            )
            flags.SOURCE_IMAGE_ARG.AddArgument(import_from_local_or_gcs,
                                               operation_type='import')

            import_from_aws = source.add_group(help='Image import from AWS.')
            daisy_utils.AddAWSImageImportSourceArgs(import_from_aws)

        workflow = parser.add_mutually_exclusive_group()
        workflow.add_argument(
            '--os',
            choices=sorted(cls._OS_CHOICES),
            help='Specifies the OS of the disk image being imported.')
        workflow.add_argument(
            '--data-disk',
            help=(
                'Specifies that the disk has no bootable OS installed on it. '
                'Imports the disk without making it bootable or installing '
                'Google tools on it.'),
            action='store_true')
        workflow.add_argument('--custom-workflow',
                              help=("""\
              Specifies a custom workflow to use for image translation. Workflow
              should be relative to the image_import directory here: []({0}).
              For example: `debian/translate_debian_9.wf.json'""".format(
                                  _WORKFLOWS_URL)),
                              hidden=True)

        daisy_utils.AddCommonDaisyArgs(parser)

        parser.add_argument(
            '--guest-environment',
            action='store_true',
            default=True,
            help='Installs the guest environment on the image.'
            ' See '
            'https://cloud.google.com/compute/docs/images/guest-environment.')

        parser.add_argument(
            '--network',
            help=
            ('Name of the network in your project to use for the image import.'
             ' The network must have access to Cloud Storage. If not '
             'specified, the network named `default` is used.'),
        )

        parser.add_argument(
            '--subnet',
            help=
            ('Name of the subnetwork in your project to use for the image '
             'import. If the network resource is in legacy mode, do not '
             'provide this property. If the network is in auto subnet mode, '
             'providing the subnetwork is optional. If the network is in '
             'custom subnet mode, then this field should be specified. '
             'Region or zone should be specified if this field is specified.'),
        )

        parser.add_argument('--family',
                            help='Family to set for the imported image.')

        parser.add_argument('--description',
                            help='Description to set for the imported image.')

        parser.display_info.AddCacheUpdater(flags.ImagesCompleter)

        parser.add_argument('--storage-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.
      """)

        parser.add_argument(
            '--sysprep-windows',
            action='store_true',
            hidden=True,
            help='Whether to generalize the image using Windows Sysprep.')

        daisy_utils.AddNoAddressArg(
            parser, 'image import',
            'https://cloud.google.com/compute/docs/import/importing-virtual-disks#no-external-ip'
        )

        daisy_utils.AddComputeServiceAccountArg(
            parser, 'image import',
            daisy_utils.IMPORT_ROLES_FOR_COMPUTE_SERVICE_ACCOUNT)
Exemple #22
0
 def Args(parser):
     Delete.DiskImageArg = flags.MakeDiskImageArg(plural=True)
     Delete.DiskImageArg.AddArgument(parser, operation_type='delete')
Exemple #23
0
    def Args(cls, parser):
        Import.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
        Import.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')

        flags.compute_flags.AddZoneFlag(
            parser,
            'image',
            'import',
            explanation=
            'The zone in which to do the work of importing the image.')

        source = parser.add_mutually_exclusive_group(required=True)
        source.add_argument(
            '--source-file',
            help=("""A local file, or the Cloud Storage URI of the virtual
              disk file to import. For example: ``gs://my-bucket/my-image.vmdk''
              or ``./my-local-image.vmdk''"""),
        )
        flags.SOURCE_IMAGE_ARG.AddArgument(source, operation_type='import')

        workflow = parser.add_mutually_exclusive_group(required=True)
        workflow.add_argument(
            '--os',
            choices=sorted(cls._OS_CHOICES),
            help='Specifies the OS of the disk image being imported.')
        workflow.add_argument(
            '--data-disk',
            help=(
                'Specifies that the disk has no bootable OS installed on it. '
                'Imports the disk without making it bootable or installing '
                'Google tools on it.'),
            action='store_true')
        workflow.add_argument('--custom-workflow',
                              help=("""\
              Specifies a custom workflow to use for image translation.
              Workflow should be relative to the image_import directory here:
              []({0}). For example: ``{1}''""".format(
                                  _WORKFLOWS_URL,
                                  os_choices.OS_CHOICES_MAP[sorted(
                                      cls._OS_CHOICES)[0]])),
                              hidden=True)

        daisy_utils.AddCommonDaisyArgs(parser)

        parser.add_argument(
            '--guest-environment',
            action='store_true',
            default=True,
            help='Installs the guest environment on the image.'
            ' See '
            'https://cloud.google.com/compute/docs/images/guest-environment.')

        parser.add_argument(
            '--network',
            help=
            ('Name of the network in your project to use for the image import.'
             ' The network must have access to Cloud Storage. If not '
             'specified, the network named `default` is used.'),
        )

        parser.add_argument(
            '--subnet',
            help=
            ('Name of the subnetwork in your project to use for the image '
             'import. If the network resource is in legacy mode, do not '
             'provide this property. If the network is in auto subnet mode, '
             'providing the subnetwork is optional. If the network is in '
             'custom subnet mode, then this field should be specified. '
             'Region or zone should be specified if this field is specified.'),
        )

        parser.add_argument('--family',
                            help='Family to set for the imported image.')

        parser.add_argument('--description',
                            help='Description to set for the imported image.')

        parser.display_info.AddCacheUpdater(flags.ImagesCompleter)

        parser.add_argument('--storage-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.
      """)
Exemple #24
0
def _Args(parser,
          messages,
          supports_force_create=False,
          support_user_licenses=False,
          support_disk_architecture=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, support_user_licenses=support_user_licenses)
    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')
    flags.AddSourceDiskProjectFlag(parser)

    # Alpha and Beta Args
    if support_disk_architecture:
        image_utils.AddArchitectureArg(parser)

    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.
    """)
    parser.add_argument('--locked',
                        action='store_true',
                        default=None,
                        hidden=True,
                        help="""\
    Specifies that any boot disk created from this image can't be used
    for data backup operations such as snapshot creation, image creation,
    instance snapshot creation, and disk cloning.

    If a VM instance is created using this image, the boot disk is fixed
    to this VM. The disk can't be attached to any other VMs, whether in
    `read-write` mode or in `read-only` mode. Also, any VM created from this
    disk, has the following characteristics:

    * The VM can't be used for creating machine images or instance templates
    * After the VM is created, you can't attach any secondary disk
    * After the VM is deleted, the attached boot disk can't be retained
    """)
    compute_flags.AddShieldedInstanceInitialStateKeyArg(parser)
 def Args(parser):
     AddIamPolicyBinding.disk_image_arg = images_flags.MakeDiskImageArg(
         plural=False)
     AddIamPolicyBinding.disk_image_arg.AddArgument(
         parser, operation_type='add the IAM policy binding to')
     iam_util.AddArgsForAddIamPolicyBinding(parser)
Exemple #26
0
 def Args(parser):
     RemoveIamPolicyBinding.disk_image_arg = images_flags.MakeDiskImageArg(
         plural=False)
     RemoveIamPolicyBinding.disk_image_arg.AddArgument(
         parser, operation_type='remove the IAM policy binding from')
     iam_util.AddArgsForRemoveIamPolicyBinding(parser)
 def Args(parser):
     base.URI_FLAG.RemoveFromParser(
         parser)  # doesn't do anything in this case
     GetIamPolicy.disk_image_arg = flags.MakeDiskImageArg(plural=False)
     GetIamPolicy.disk_image_arg.AddArgument(
         parser, operation_type='get the IAM policy of')
Exemple #28
0
 def Args(cls, parser):
     cls.DISK_IMAGE_ARG = images_flags.MakeDiskImageArg(plural=False)
     cls.DISK_IMAGE_ARG.AddArgument(parser)
     labels_flags.AddArgsForRemoveLabels(parser)
    def Args(cls, parser):
        compute_holder = cls._GetComputeApiHolder(no_http=True)
        compute_client = compute_holder.client
        messages = compute_client.messages

        Import.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
        Import.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')

        flags.compute_flags.AddZoneFlag(
            parser,
            'image',
            'import',
            help_text='Zone to use when importing the image. When you import '
            'an image, the import tool creates and uses temporary VMs '
            'in your project for the import process. Use this flag to '
            'specify the zone to use for these temporary VMs.')

        if cls.ReleaseTrack() == base.ReleaseTrack.GA:
            source = parser.add_mutually_exclusive_group(required=True)
            source.add_argument(
                '--source-file',
                help=("""A local file, or the Cloud Storage URI of the virtual
              disk file to import. For example: ``gs://my-bucket/my-image.vmdk''
              or ``./my-local-image.vmdk''. For more information about Cloud
              Storage URIs, see
              https://cloud.google.com/storage/docs/request-endpoints#json-api.
              """),
            )
            flags.SOURCE_IMAGE_ARG.AddArgument(source, operation_type='import')
        else:
            source = parser.add_mutually_exclusive_group(required=True)

            import_from_local_or_gcs = source.add_mutually_exclusive_group(
                help=
                'Image import from local file, Cloud Storage or Compute Engine image.'
            )
            import_from_local_or_gcs.add_argument(
                '--source-file',
                help=("""A local file, or the Cloud Storage URI of the virtual
                disk file to import. For example: ``gs://my-bucket/my-image.vmdk''
                or ``./my-local-image.vmdk''. For more information about Cloud
              Storage URIs, see
              https://cloud.google.com/storage/docs/request-endpoints#json-api.
              """),
            )
            flags.SOURCE_IMAGE_ARG.AddArgument(import_from_local_or_gcs,
                                               operation_type='import')

            import_from_aws = source.add_group(help='Image import from AWS.')
            daisy_utils.AddAWSImageImportSourceArgs(import_from_aws)

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

        workflow = parser.add_mutually_exclusive_group()
        os_group = workflow.add_group()
        daisy_utils.AddByolArg(os_group)
        os_group.add_argument(
            '--os',
            choices=sorted(cls._OS_CHOICES),
            help='Specifies the OS of the disk image being imported.')

        workflow.add_argument(
            '--data-disk',
            help=(
                'Specifies that the disk has no bootable OS installed on it. '
                'Imports the disk without making it bootable or installing '
                'Google tools on it.'),
            action='store_true')
        workflow.add_argument('--custom-workflow',
                              help=("""\
              Specifies a custom workflow to use for image translation. Workflow
              should be relative to the image_import directory here: []({0}).
              For example: `debian/translate_debian_9.wf.json'""".format(
                                  _WORKFLOWS_URL)),
                              hidden=True)

        daisy_utils.AddCommonDaisyArgs(parser,
                                       operation='an import',
                                       extra_timeout_help=("""

          If you are importing a large image that takes longer than 24 hours to
          import, either use the RAW disk format to reduce the time needed for
          converting the image, or split the data into several smaller images.
          """))

        parser.add_argument(
            '--guest-environment',
            action='store_true',
            default=True,
            help='Installs the guest environment on the image.'
            ' See '
            'https://cloud.google.com/compute/docs/images/guest-environment.')

        parser.add_argument(
            '--network',
            help=
            ('Name of the network in your project to use for the image '
             'import. When you import an image, the import tool creates and '
             'uses temporary VMs in your project for the import process. Use '
             'this flag to specify the network to use for these temporary VMs.'
             ),
        )

        parser.add_argument(
            '--subnet',
            help=("""\
      Name of the subnetwork in your project to use for the image import. When
      you import an image, the import tool creates and uses temporary VMs in
      your project for the import process. Use this flag to specify the
      subnetwork to use for these temporary VMs.
          * If the network resource is in legacy mode, do not provide this
            property.
          * If the network is in auto subnet mode, specifying the subnetwork is
            optional.
          * If the network is in custom subnet mode, then this field must be
            specified.
        """),
        )

        parser.add_argument('--family',
                            help='Family to set for the imported image.')

        parser.add_argument('--description',
                            help='Description to set for the imported image.')

        parser.display_info.AddCacheUpdater(flags.ImagesCompleter)

        parser.add_argument('--storage-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.
      """)

        parser.add_argument(
            '--sysprep-windows',
            action='store_true',
            hidden=True,
            help='Whether to generalize the image using Windows Sysprep.')

        daisy_utils.AddNoAddressArg(
            parser, 'image import',
            'https://cloud.google.com/compute/docs/import/importing-virtual-disks#no-external-ip'
        )

        daisy_utils.AddComputeServiceAccountArg(
            parser, 'image import',
            daisy_utils.IMPORT_ROLES_FOR_COMPUTE_SERVICE_ACCOUNT)