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')
Exemplo n.º 2
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 _CommonArgs(parser,
                deprecate_maintenance_policy=False,
                support_min_node_cpu=False,
                support_erase_vss=False,
                snapshot_csek=False,
                image_csek=False,
                support_display_device=False,
                support_local_ssd_size=False,
                support_numa_node_count=False,
                support_visible_core_count=False,
                support_max_run_duration=False,
                support_enable_target_shape=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgsForBulk(parser)
    instances_flags.AddCreateDiskArgs(parser,
                                      enable_kms=True,
                                      enable_snapshots=True,
                                      source_snapshot_csek=snapshot_csek,
                                      image_csek=image_csek,
                                      include_name=False,
                                      support_boot=True)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAcceleratorArgs(parser)
    instances_flags.AddMachineTypeArgs(parser)
    instances_flags.AddMaintenancePolicyArgs(
        parser, deprecate=deprecate_maintenance_policy)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddProvisioningModelVmArgs(parser)
    instances_flags.AddNetworkPerformanceConfigsArgs(parser)
    instances_flags.AddInstanceTerminationActionVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(
        parser,
        False,
        extra_scopes_help='However, if neither `--scopes` nor `--no-scopes` are '
        'specified and the project has no default service '
        'account, then the instance will be created with no '
        'scopes. Note that the level of access that a service '
        'account has is determined by a combination of access '
        'scopes and IAM roles so you must configure both '
        'access scopes and IAM roles for the service account '
        'to work properly.')
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddNoAddressArg(parser)
    instances_flags.AddNetworkArgs(parser)
    instances_flags.AddNetworkTierArgs(parser, instance=True)
    instances_flags.AddBulkCreateNetworkingArgs(parser)

    instances_flags.AddImageArgs(parser, enable_snapshots=True)
    instances_flags.AddShieldedInstanceConfigArgs(parser)
    instances_flags.AddNestedVirtualizationArgs(parser)
    instances_flags.AddThreadsPerCoreArgs(parser)
    instances_flags.AddEnableUefiNetworkingArgs(parser)
    instances_flags.AddResourceManagerTagsArgs(parser)
    if support_numa_node_count:
        instances_flags.AddNumaNodeCountArgs(parser)

    if support_display_device:
        instances_flags.AddDisplayDeviceArg(parser)

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

    maintenance_flags.AddResourcePoliciesArgs(parser, 'added to', 'instance')

    if support_min_node_cpu:
        instances_flags.AddMinNodeCpuArg(parser)

    instances_flags.AddLocationHintArg(parser)

    if support_erase_vss:
        flags.AddEraseVssSignature(
            parser, 'source snapshots or source machine'
            ' image')

    labels_util.AddCreateLabelsFlags(parser)

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

    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(
        'multi(instances:format="table(name,zone.basename())")')

    if support_visible_core_count:
        instances_flags.AddVisibleCoreCountArgs(parser)

    if support_local_ssd_size:
        instances_flags.AddLocalSsdArgsWithSize(parser)
    else:
        instances_flags.AddLocalSsdArgs(parser)

    if support_max_run_duration:
        instances_flags.AddMaxRunDurationVmArgs(parser)

    if support_enable_target_shape:
        instances_flags.AddDistributionTargetShapeArgs(parser)
Exemplo n.º 4
0
def _CommonArgs(parser,
                deprecate_maintenance_policy=False,
                enable_resource_policy=False,
                supports_min_node_cpu=False,
                supports_location_hint=False,
                supports_erase_vss=False,
                snapshot_csek=False,
                image_csek=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddCreateDiskArgs(parser,
                                      enable_snapshots=True,
                                      resource_policy=enable_resource_policy,
                                      source_snapshot_csek=snapshot_csek,
                                      image_csek=image_csek,
                                      include_name=False)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAcceleratorArgs(parser)
    instances_flags.AddMachineTypeArgs(parser)
    instances_flags.AddMaintenancePolicyArgs(
        parser, deprecate=deprecate_maintenance_policy)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(
        parser,
        False,
        extra_scopes_help='However, if neither `--scopes` nor `--no-scopes` are '
        'specified and the project has no default service '
        'account, then the instance will be created with no '
        'scopes. Note that the level of access that a service '
        'account has is determined by a combination of access '
        'scopes and IAM roles so you must configure both '
        'access scopes and IAM roles for the service account '
        'to work properly.')
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddNoAddressArg(parser)
    instances_flags.AddNetworkArgs(parser)
    instances_flags.AddNetworkTierArgs(parser, instance=True)
    instances_flags.AddBulkCreateNetworkingArgs(parser)

    instances_flags.AddImageArgs(parser, enable_snapshots=True)
    instances_flags.AddShieldedInstanceConfigArgs(parser)
    instances_flags.AddDisplayDeviceArg(parser)

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

    maintenance_flags.AddResourcePoliciesArgs(parser, 'added to', 'instance')

    if supports_min_node_cpu:
        instances_flags.AddMinNodeCpuArg(parser)

    if supports_location_hint:
        instances_flags.AddLocationHintArg(parser)

    if supports_erase_vss:
        flags.AddEraseVssSignature(
            parser, 'source snapshots or source machine'
            ' image')

    labels_util.AddCreateLabelsFlags(parser)

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

    base.ASYNC_FLAG.AddToParser(parser)