def Args(cls, parser):
        compute_holder = cls._GetComputeApiHolder(no_http=True)
        messages = compute_holder.client.messages

        instances_flags.AddCanIpForwardArgs(parser)
        instances_flags.AddMachineTypeArgs(parser)
        instances_flags.AddNoRestartOnFailureArgs(parser)
        instances_flags.AddTagsArgs(parser)
        instances_flags.AddCustomMachineTypeArgs(parser)
        instances_flags.AddNetworkArgs(parser)
        instances_flags.AddPrivateNetworkIpArgs(parser)
        instances_flags.AddDeletionProtectionFlag(parser)
        instances_flags.AddNetworkTierArgs(parser, instance=True)
        instances_flags.AddNoAddressArg(parser)
        labels_util.AddCreateLabelsFlags(parser)
        daisy_utils.AddCommonDaisyArgs(parser, operation='an import')
        daisy_utils.AddExtraCommonDaisyArgs(parser)
        instances_flags.INSTANCES_ARG_FOR_IMPORT.AddArgument(
            parser, operation_type='import')
        daisy_utils.AddOVFSourceUriArg(parser)
        parser.add_argument(
            '--os',
            required=False,
            choices=sorted(cls._OS_CHOICES),
            help='Specifies the OS of the image being imported.')
        daisy_utils.AddByolArg(parser)

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

        parser.add_argument(
            '--description',
            help='Specifies a textual description of the VM instances.')
        daisy_utils.AddGuestEnvironmentArg(parser)
        parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
        sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)
        parser.add_argument('--hostname',
                            help="""\
      Specify the hostname of the VM instance to be imported. The specified
      hostname must be RFC1035 compliant. If hostname is not specified, the
      default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal when using
      the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal
      when using zonal DNS.
      """)
        daisy_utils.AddComputeServiceAccountArg(
            parser, 'instance 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 VM instance 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')
Beispiel #2
0
  def Args(parser):
    image_group = parser.add_mutually_exclusive_group(required=True)

    image_group.add_argument(
        '--image',
        help=('The name of the disk image to export.'),
    )
    image_group.add_argument(
        '--image-family',
        help=('The family of the disk image to be exported. When a family '
              'is used instead of an image, the latest non-deprecated image '
              'associated with that family is used.'),
    )
    image_utils.AddImageProjectFlag(parser)

    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)
Beispiel #3
0
    def Args(parser):
        image_group = parser.add_mutually_exclusive_group(required=True)

        image_group.add_argument(
            '--image',
            help='The name of the disk image to export.',
        )
        image_group.add_argument(
            '--image-family',
            help=(
                'The family of the disk image to be exported. When a family '
                'is used instead of an image, the latest non-deprecated image '
                'associated with that family is used.'),
        )
        image_utils.AddImageProjectFlag(parser)

        flags.compute_flags.AddZoneFlag(
            parser,
            'image',
            'export',
            explanation='The zone to use when exporting the image.')

        parser.add_argument(
            '--destination-uri',
            required=True,
            help=('The 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`.'),
        )

        parser.add_argument(
            '--network',
            help=(
                'The name of the network in your project to use for the image '
                'export. 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 '
                'export. 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.'),
        )

        daisy_utils.AddCommonDaisyArgs(parser)

        parser.display_info.AddCacheUpdater(flags.ImagesCompleter)
Beispiel #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)
Beispiel #5
0
    def Args(cls, parser):
        instances_flags.AddCanIpForwardArgs(parser)
        instances_flags.AddMachineTypeArgs(parser)
        instances_flags.AddNoRestartOnFailureArgs(parser)
        instances_flags.AddTagsArgs(parser)
        instances_flags.AddCustomMachineTypeArgs(parser)
        instances_flags.AddNetworkArgs(parser)
        instances_flags.AddPrivateNetworkIpArgs(parser)
        instances_flags.AddDeletionProtectionFlag(parser)
        instances_flags.AddNetworkTierArgs(parser, instance=True)
        labels_util.AddCreateLabelsFlags(parser)
        daisy_utils.AddCommonDaisyArgs(parser, add_log_location=False)
        daisy_utils.AddExtraCommonDaisyArgs(parser)

        instances_flags.INSTANCES_ARG_FOR_IMPORT.AddArgument(
            parser, operation_type='import')

        parser.add_argument(
            '--source-uri',
            required=True,
            help=('Google Cloud Storage path to one of:\n  OVF descriptor\n  '
                  'OVA file\n  Directory with OVF package'))

        parser.add_argument(
            '--os',
            required=False,
            choices=sorted(os_choices.OS_CHOICES_INSTANCE_IMPORT_BETA),
            help='Specifies the OS of the image being imported.')

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

        parser.add_argument(
            '--guest-environment',
            action='store_true',
            default=True,
            help='Google Guest Environment will be installed on the instance.')

        parser.display_info.AddCacheUpdater(completers.InstancesCompleter)

        sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)

        parser.add_argument('--hostname',
                            help="""\
      Specify the hostname of the instance to be imported. The specified
      hostname must be RFC1035 compliant. If hostname is not specified, the
      default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal when using
      the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal
      when using zonal DNS.
      """)
    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)
Beispiel #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'
    )
    def Args(parser):
        flags.DESTINATION_IMAGE_ARG.AddArgument(parser,
                                                operation_type='create')
        flags.SOURCE_IMAGE_ARG.AddArgument(parser, 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(
            '--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: ``debian/translate_debian_8.wf.json''""".
                  format(_WORKFLOWS_URL)),
        )
        daisy_utils.AddCommonDaisyArgs(parser)
Beispiel #9
0
    def Args(cls, parser):
        instances_flags.AddCanIpForwardArgs(parser)
        instances_flags.AddMachineTypeArgs(parser)
        instances_flags.AddNoRestartOnFailureArgs(parser)
        instances_flags.AddTagsArgs(parser)
        instances_flags.AddCustomMachineTypeArgs(parser)
        instances_flags.AddNetworkArgs(parser)
        instances_flags.AddPrivateNetworkIpArgs(parser)
        instances_flags.AddDeletionProtectionFlag(parser)
        instances_flags.AddNetworkTierArgs(parser, instance=True)
        instances_flags.AddNoAddressArg(parser)
        labels_util.AddCreateLabelsFlags(parser)
        daisy_utils.AddCommonDaisyArgs(parser)
        daisy_utils.AddExtraCommonDaisyArgs(parser)

        instances_flags.INSTANCES_ARG_FOR_IMPORT.AddArgument(
            parser, operation_type='import')

        daisy_utils.AddOVFSourceUriArg(parser)

        parser.add_argument(
            '--os',
            required=False,
            choices=sorted(cls._OS_CHOICES),
            help='Specifies the OS of the image being imported.')

        parser.add_argument(
            '--description',
            help='Specifies a textual description of the instances.')
        daisy_utils.AddGuestEnvironmentArg(parser)
        parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
        sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)

        parser.add_argument('--hostname',
                            help="""\
      Specify the hostname of the instance to be imported. The specified
      hostname must be RFC1035 compliant. If hostname is not specified, the
      default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal when using
      the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal
      when using zonal DNS.
      """)
    def Args(cls, parser):
        instances_flags.AddCanIpForwardArgs(parser)
        instances_flags.AddMachineTypeArgs(parser)
        instances_flags.AddNoRestartOnFailureArgs(parser)
        instances_flags.AddTagsArgs(parser)
        instances_flags.AddCustomMachineTypeArgs(parser)
        instances_flags.AddNetworkArgs(parser)
        instances_flags.AddPrivateNetworkIpArgs(parser)
        instances_flags.AddDeletionProtectionFlag(parser)
        instances_flags.AddNetworkTierArgs(parser, instance=True)
        labels_util.AddCreateLabelsFlags(parser)
        daisy_utils.AddCommonDaisyArgs(parser, add_log_location=False)

        instances_flags.INSTANCES_ARG_FOR_IMPORT.AddArgument(
            parser, operation_type='import')

        parser.add_argument(
            '--source-uri',
            required=True,
            help=('Google Cloud Storage path to one of:\n  OVF descriptor\n  '
                  'OVA file\n  Directory with OVF package'))

        parser.add_argument(
            '--os',
            required=True,
            choices=sorted(os_choices.OS_CHOICES_INSTANCE_IMPORT_ALPHA),
            help='Specifies the OS of the image being imported.')

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

        parser.add_argument(
            '--guest-environment',
            action='store_true',
            default=True,
            help='Google Guest Environment will be installed on the instance.')

        parser.display_info.AddCacheUpdater(completers.InstancesCompleter)

        sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)
Beispiel #11
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)
Beispiel #12
0
  def Args(cls, parser):
    parser.add_argument(
        '--source-os',
        required=True,
        choices=sorted(_OS_CHOICES_SOURCE),
        help='OS version of the source instance to upgrade.')
    parser.add_argument(
        '--target-os',
        required=True,
        choices=sorted(_OS_CHOICES_TARGET),
        help='Version of the OS after upgrade.')

    parser.add_argument(
        '--create-machine-backup',
        required=False,
        action='store_true',
        default=True,
        help='When enabled, a machine image is created that backs up the '
             'original state of your instance.')
    parser.add_argument(
        '--auto-rollback',
        required=False,
        action='store_true',
        help='When auto rollback is enabled, the instance and its resources '
             'are restored to their original state. Otherwise, the instance '
             'and any temporary resources are left in the intermediate state '
             'of the time of failure. This is useful for debugging.')
    parser.add_argument(
        '--use-staging-install-media',
        required=False,
        action='store_true',
        help='Use staging install media. This flag is for testing only. Set to '
             'true to upgrade with staging windows install media.',
        hidden=True)

    daisy_utils.AddCommonDaisyArgs(parser)
    daisy_utils.AddExtraCommonDaisyArgs(parser)

    flags.INSTANCES_ARG_FOR_OS_UPGRADE.AddArgument(
        parser, operation_type=_OS_UPGRADE_OPERATION_TYPE)
Beispiel #13
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(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)
Beispiel #15
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)
Beispiel #16
0
    def Args(parser):
        image_group = parser.add_mutually_exclusive_group(required=True)

        image_group.add_argument(
            '--image',
            help='The name of the disk image to export.',
        )
        image_group.add_argument(
            '--image-family',
            help=(
                'The family of the disk image to be exported. When a family '
                'is used instead of an image, the latest non-deprecated image '
                'associated with that family is used.'),
        )
        image_utils.AddImageProjectFlag(parser)

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

        parser.add_argument(
            '--destination-uri',
            required=True,
            help=('The 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`.'),
        )

        parser.add_argument(
            '--network',
            help=
            ('The name of the network in your project to use for the image '
             'export. When you export an image, the export tool creates and '
             'uses temporary VMs in your project for the export 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 export. When
      you export an image, the export tool creates and uses temporary VMs in
      your project for the export 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.
        """)

        daisy_utils.AddComputeServiceAccountArg(
            parser, 'image export',
            daisy_utils.EXPORT_ROLES_FOR_COMPUTE_SERVICE_ACCOUNT)

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

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

        parser.display_info.AddCacheUpdater(flags.ImagesCompleter)
    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')
Beispiel #18
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.
      """)