예제 #1
0
파일: create.py 프로젝트: linsole/CS61A
 def Args(cls, parser):
   _CommonArgs(
       parser,
       enable_regional=True,
       enable_kms=True,
       deprecate_maintenance_policy=True,
       enable_resource_policy=cls._support_disk_resource_policy,
       supports_min_node_cpus=cls._support_min_node_cpus,
       supports_location_hint=cls._support_location_hint,
       snapshot_csek=True,
       image_csek=True)
   CreateAlpha.SOURCE_INSTANCE_TEMPLATE = (
       instances_flags.MakeSourceInstanceTemplateArg())
   CreateAlpha.SOURCE_INSTANCE_TEMPLATE.AddArgument(parser)
   CreateAlpha.SOURCE_MACHINE_IMAGE = (
       instances_flags.AddMachineImageArg())
   CreateAlpha.SOURCE_MACHINE_IMAGE.AddArgument(parser)
   instances_flags.AddSourceMachineImageEncryptionKey(parser)
   instances_flags.AddMinCpuPlatformArgs(parser, base.ReleaseTrack.ALPHA)
   instances_flags.AddPublicDnsArgs(parser, instance=True)
   instances_flags.AddLocalSsdArgsWithSize(parser)
   instances_flags.AddLocalNvdimmArgs(parser)
   flags.AddEraseVssSignature(parser, 'source snapshots or source machine'
                                      ' image')
   maintenance_flags.AddResourcePoliciesArgs(parser, 'added to', 'instance')
   instances_flags.AddConfidentialComputeArgs(parser)
예제 #2
0
 def Args(cls, parser):
     _CommonArgs(parser,
                 enable_regional=True,
                 enable_kms=True,
                 enable_snapshots=True,
                 deprecate_maintenance_policy=True,
                 supports_display_device=True,
                 supports_reservation=cls._support_reservation,
                 enable_resource_policy=cls._support_disk_resource_policy)
     CreateAlpha.SOURCE_INSTANCE_TEMPLATE = (
         instances_flags.MakeSourceInstanceTemplateArg())
     CreateAlpha.SOURCE_INSTANCE_TEMPLATE.AddArgument(parser)
     CreateAlpha.SOURCE_MACHINE_IMAGE = (
         instances_flags.AddMachineImageArg())
     CreateAlpha.SOURCE_MACHINE_IMAGE.AddArgument(parser)
     instances_flags.AddMinCpuPlatformArgs(parser, base.ReleaseTrack.ALPHA)
     instances_flags.AddPublicDnsArgs(parser, instance=True)
     instances_flags.AddLocalSsdArgsWithSize(parser)
     instances_flags.AddLocalNvdimmArgs(parser)
     flags.AddEraseVssSignature(
         parser, 'source snapshots or source machine'
         ' image')
     maintenance_flags.AddResourcePoliciesArgs(parser, 'added to',
                                               'instance')
예제 #3
0
def _CommonArgs(parser,
                include_physical_block_size_support=False,
                vss_erase_enabled=False,
                source_disk_enabled=False):
  """Add arguments used for parsing in all command tracks."""
  Create.disks_arg.AddArgument(parser, operation_type='create')
  parser.add_argument(
      '--description',
      help='An optional, textual description for the disks being created.')

  parser.add_argument(
      '--size',
      type=arg_parsers.BinarySize(
          lower_bound='1GB',
          suggested_binary_size_scales=['GB', 'GiB', 'TB', 'TiB', 'PiB', 'PB']),
      help="""\
        Size of the disks. The value must be a whole
        number followed by a size unit of ``GB'' for gigabyte, or ``TB''
        for terabyte. If no size unit is specified, GB is
        assumed. For example, ``10GB'' will produce 10 gigabyte
        disks. Disk size must be a multiple of 1 GB. Limit your boot disk size
        to 2TB to account for MBR partition table limitations. If disk size is
        not specified, the default size of {}GB for standard disks and {}GB for
        pd-ssd disks will be used.
        """.format(constants.DEFAULT_STANDARD_DISK_SIZE_GB,
                   constants.DEFAULT_SSD_DISK_SIZE_GB))

  parser.add_argument(
      '--type',
      completer=completers.DiskTypesCompleter,
      help="""\
      Specifies the type of disk to create. To get a
      list of available disk types, run `gcloud compute disk-types list`.
      The default disk type is pd-standard.
      """)

  parser.display_info.AddFormat(
      'table(name, zone.basename(), sizeGb, type.basename(), status)')

  parser.add_argument(
      '--licenses',
      type=arg_parsers.ArgList(),
      metavar='LICENSE',
      help=('A list of URIs to license resources. The provided licenses will '
            'be added onto the created disks to indicate the licensing and '
            'billing policies.'))

  _SourceArgs(parser, source_disk_enabled)

  csek_utils.AddCsekKeyArgs(parser)
  labels_util.AddCreateLabelsFlags(parser)

  if include_physical_block_size_support:
    parser.add_argument(
        '--physical-block-size',
        choices=['4096', '16384'],
        default='4096',
        help="""\
Physical block size of the persistent disk in bytes.
Valid values are 4096(default) and 16384.
""")
  if vss_erase_enabled:
    flags.AddEraseVssSignature(parser, resource='a source snapshot')

  resource_flags.AddResourcePoliciesArgs(parser, 'added to', 'disk')
예제 #4
0
def _CommonArgs(parser,
                include_physical_block_size_support=False,
                vss_erase_enabled=False,
                source_instant_snapshot_enabled=False,
                support_pd_interface=False,
                support_provisioned_iops=False):
    """Add arguments used for parsing in all command tracks."""
    Create.disks_arg.AddArgument(parser, operation_type='create')
    parser.add_argument(
        '--description',
        help='An optional, textual description for the disks being created.')

    # TODO(b/158105562) Add help text for pd-extreme before GA.
    parser.add_argument(
        '--size',
        type=arg_parsers.BinarySize(lower_bound='10GB',
                                    suggested_binary_size_scales=[
                                        'GB', 'GiB', 'TB', 'TiB', 'PiB', 'PB'
                                    ]),
        help="""\
        Size of the disks. The value must be a whole
        number followed by a size unit of ``GB'' for gigabyte, or ``TB''
        for terabyte. If no size unit is specified, GB is
        assumed. For example, ``10GB'' will produce 10 gigabyte
        disks. Disk size must be a multiple of 1 GB. Limit your boot disk size
        to 2TB to account for MBR partition table limitations. If disk size is
        not specified, the default size of {}GB for pd-standard disks, {}GB for
        pd-balanced disks, and {}GB for pd-ssd disks will be used. For details
        about disk size limits, refer to:
        https://cloud.google.com/compute/docs/disks
        """.format(
            constants.DEFAULT_DISK_SIZE_GB_MAP[
                constants.DISK_TYPE_PD_STANDARD],
            constants.DEFAULT_DISK_SIZE_GB_MAP[
                constants.DISK_TYPE_PD_BALANCED],
            constants.DEFAULT_DISK_SIZE_GB_MAP[constants.DISK_TYPE_PD_SSD]))

    parser.add_argument('--type',
                        completer=completers.DiskTypesCompleter,
                        help="""\
      Specifies the type of disk to create. To get a
      list of available disk types, run `gcloud compute disk-types list`.
      The default disk type is pd-standard.
      """)

    if support_pd_interface:
        parser.add_argument('--interface',
                            help="""\
        Specifies the disk interface to use for attaching this disk. Valid values
        are `SCSI` and `NVME`. The default is `SCSI`.
        """)

    parser.display_info.AddFormat(
        'table(name, zone.basename(), sizeGb, type.basename(), status)')

    parser.add_argument(
        '--licenses',
        type=arg_parsers.ArgList(),
        metavar='LICENSE',
        help=(
            'A list of URIs to license resources. The provided licenses will '
            'be added onto the created disks to indicate the licensing and '
            'billing policies.'))

    _SourceArgs(parser, source_instant_snapshot_enabled)

    if support_provisioned_iops:
        parser.add_argument(
            '--provisioned-iops',
            type=arg_parsers.BoundedInt(constants.MIN_PROVISIONED_IOPS,
                                        constants.MAX_PROVISIONED_IOPS),
            help=
            ('Provisioned IOPS of pd-extreme disk to create. If specified, '
             'the value must be in the range between {min} and {max}. If not '
             'specified, the default value is {default}.').format(
                 min=constants.MIN_PROVISIONED_IOPS,
                 max=constants.MAX_PROVISIONED_IOPS,
                 default=constants.DEFAULT_PROVISIONED_IOPS))

    csek_utils.AddCsekKeyArgs(parser)
    labels_util.AddCreateLabelsFlags(parser)

    if include_physical_block_size_support:
        parser.add_argument('--physical-block-size',
                            choices=['4096', '16384'],
                            default='4096',
                            help="""\
Physical block size of the persistent disk in bytes.
Valid values are 4096(default) and 16384.
""")
    if vss_erase_enabled:
        flags.AddEraseVssSignature(parser, resource='a source snapshot')

    resource_flags.AddResourcePoliciesArgs(parser, 'added to', 'disk')
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)
예제 #6
0
파일: create.py 프로젝트: iofh/QA-System
def _CommonArgs(parser,
                enable_regional=False,
                enable_kms=False,
                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,
                enable_pd_interface=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser,
                                enable_regional,
                                enable_kms=enable_kms,
                                enable_pd_interface=enable_pd_interface)
    instances_flags.AddCreateDiskArgs(parser,
                                      enable_kms=enable_kms,
                                      enable_snapshots=True,
                                      resource_policy=enable_resource_policy,
                                      source_snapshot_csek=snapshot_csek,
                                      image_csek=image_csek)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(parser, instances=True)
    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.AddNetworkArgs(parser)
    instances_flags.AddPrivateNetworkIpArgs(parser)
    instances_flags.AddHostnameArg(parser)
    instances_flags.AddImageArgs(parser, enable_snapshots=True)
    instances_flags.AddDeletionProtectionFlag(parser)
    instances_flags.AddPublicPtrArgs(parser, instance=True)
    instances_flags.AddNetworkTierArgs(parser, instance=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')

    sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)

    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.')

    instances_flags.INSTANCES_ARG_FOR_CREATE.AddArgument(
        parser, operation_type='create')

    csek_utils.AddCsekKeyArgs(parser)

    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(
        resource_registry.RESOURCE_REGISTRY['compute.instances'].list_format)
    parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
예제 #7
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)
예제 #8
0
def _CommonArgs(parser,
                enable_regional=False,
                enable_kms=False,
                deprecate_maintenance_policy=False,
                supports_erase_vss=False,
                snapshot_csek=False,
                image_csek=False,
                support_multi_writer=False,
                support_replica_zones=False,
                support_subinterface=False,
                support_node_project=False,
                support_host_error_timeout_seconds=False,
                support_numa_node_count=False,
                support_disk_architecture=False,
                support_network_queue_count=False,
                support_instance_kms=False,
                support_max_run_duration=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser, enable_regional, enable_kms=enable_kms)
    instances_flags.AddCreateDiskArgs(
        parser,
        enable_kms=enable_kms,
        enable_snapshots=True,
        source_snapshot_csek=snapshot_csek,
        image_csek=image_csek,
        support_boot=True,
        support_multi_writer=support_multi_writer,
        support_replica_zones=support_replica_zones,
        support_disk_architecture=support_disk_architecture)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(
        parser,
        instances=True,
        support_subinterface=support_subinterface,
        instance_create=True,
        support_network_queue_count=support_network_queue_count)
    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.AddNetworkArgs(parser)
    instances_flags.AddPrivateNetworkIpArgs(parser)
    instances_flags.AddHostnameArg(parser)
    instances_flags.AddImageArgs(parser,
                                 enable_snapshots=True,
                                 support_image_family_scope=True)
    instances_flags.AddDeletionProtectionFlag(parser)
    instances_flags.AddPublicPtrArgs(parser, instance=True)
    instances_flags.AddIpv6PublicPtrDomainArg(parser)
    instances_flags.AddNetworkTierArgs(parser, instance=True)
    instances_flags.AddShieldedInstanceConfigArgs(parser)
    instances_flags.AddDisplayDeviceArg(parser)
    instances_flags.AddMinNodeCpuArg(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)
    instances_flags.AddStackTypeArgs(parser)
    instances_flags.AddIpv6NetworkTierArgs(parser)
    instances_flags.AddNetworkPerformanceConfigsArgs(parser)
    instances_flags.AddProvisioningModelVmArgs(parser)
    instances_flags.AddInstanceTerminationActionVmArgs(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')

    sole_tenancy_flags.AddNodeAffinityFlagToParser(parser)

    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.')

    instances_flags.INSTANCES_ARG_FOR_CREATE.AddArgument(
        parser, operation_type='create')

    csek_utils.AddCsekKeyArgs(parser)

    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(instances_flags.DEFAULT_LIST_FORMAT)
    parser.display_info.AddCacheUpdater(completers.InstancesCompleter)

    if support_node_project:
        instances_flags.AddNodeProjectArgs(parser)

    if support_host_error_timeout_seconds:
        instances_flags.AddHostErrorTimeoutSecondsArgs(parser)

    if support_instance_kms:
        instances_flags.AddInstanceKmsArgs(parser)

    if support_max_run_duration:
        instances_flags.AddMaxRunDurationVmArgs(parser)