Пример #1
0
def _AddDiskArgsDeprecated(parser):
    """Adds deprecated disk related args to the parser."""
    master_boot_disk_size = parser.add_mutually_exclusive_group()
    worker_boot_disk_size = parser.add_mutually_exclusive_group()

    # Deprecated, to be removed at a future date.
    master_boot_disk_size.add_argument(
        '--master-boot-disk-size-gb',
        action=actions.DeprecationAction(
            '--master-boot-disk-size-gb',
            warn=(
                'The `--master-boot-disk-size-gb` flag is deprecated. '
                'Use `--master-boot-disk-size` flag with "GB" after value.')),
        type=int,
        hidden=True,
        help='Use `--master-boot-disk-size` flag with "GB" after value.')
    worker_boot_disk_size.add_argument(
        '--worker-boot-disk-size-gb',
        action=actions.DeprecationAction(
            '--worker-boot-disk-size-gb',
            warn=(
                'The `--worker-boot-disk-size-gb` flag is deprecated. '
                'Use `--worker-boot-disk-size` flag with "GB" after value.')),
        type=int,
        hidden=True,
        help='Use `--worker-boot-disk-size` flag with "GB" after value.')

    boot_disk_size_detailed_help = """\
      The size of the boot disk. The value must be a
      whole number followed by a size unit of ``KB'' for kilobyte, ``MB''
      for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For example,
      ``10GB'' will produce a 10 gigabyte disk. The minimum size a boot disk
      can have is 10 GB. Disk size must be a multiple of 1 GB.
      """
    master_boot_disk_size.add_argument(
        '--master-boot-disk-size',
        type=arg_parsers.BinarySize(lower_bound='10GB'),
        help=boot_disk_size_detailed_help)
    worker_boot_disk_size.add_argument(
        '--worker-boot-disk-size',
        type=arg_parsers.BinarySize(lower_bound='10GB'),
        help=boot_disk_size_detailed_help)
    parser.add_argument('--preemptible-worker-boot-disk-size',
                        type=arg_parsers.BinarySize(lower_bound='10GB'),
                        help=boot_disk_size_detailed_help)
 def AddMemory(self):
     self._AddFlag(
         '--memory',
         type=arg_parsers.BinarySize(default_unit='B'),
         help=
         'Container memory limit. Limit is expressed either as an integer '
         'representing the number of bytes or an integer followed by a unit '
         'suffix. Valid unit suffixes are "B", "KB", "MB", "GB", "TB", "KiB", '
         '"MiB", "GiB", "TiB", or "PiB".')
Пример #3
0
def _AddDiskArgs(parser):
    """Adds disk related args to the parser."""
    boot_disk_size_detailed_help = """\
      The size of the boot disk. The value must be a
      whole number followed by a size unit of ``KB'' for kilobyte, ``MB''
      for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For example,
      ``10GB'' will produce a 10 gigabyte disk. The minimum size a boot disk
      can have is 10 GB. Disk size must be a multiple of 1 GB.
      """
    parser.add_argument('--master-boot-disk-size',
                        type=arg_parsers.BinarySize(lower_bound='10GB'),
                        help=boot_disk_size_detailed_help)
    parser.add_argument('--worker-boot-disk-size',
                        type=arg_parsers.BinarySize(lower_bound='10GB'),
                        help=boot_disk_size_detailed_help)
    parser.add_argument('--preemptible-worker-boot-disk-size',
                        type=arg_parsers.BinarySize(lower_bound='10GB'),
                        help=boot_disk_size_detailed_help)
Пример #4
0
def AddStorageSize(parser):
    parser.add_argument(
        '--storage-size',
        type=arg_parsers.BinarySize(lower_bound='10GB',
                                    upper_bound='10230GB',
                                    suggested_binary_size_scales=['GB']),
        help=(
            'Amount of storage allocated to the instance. Must be an integer '
            'number of GB between 10GB and 10230GB inclusive.'))
Пример #5
0
 def Args(parser):
   """Args is called by calliope to gather arguments for this command."""
   _BaseCreate.Args(parser)
   parser.add_argument(
       '--storage-type',
       required=False,
       choices=['SSD', 'HDD'],
       default=None,
       help='The storage type for the instance.')
   parser.add_argument(
       '--failover-replica-name',
       required=False,
       help='Also create a failover replica with the specified name.')
   base.Argument(
       '--storage-auto-increase',
       action='store_true',
       default=None,
       help='Adds storage capacity whenever space is low. Up to 25 GB per '
       'increase. All increases are permanent.',
       detailed_help='Storage size can be increased, but it cannot be '
       'decreased; storage increases are permanent for the life of the '
       'instance. With this setting enabled, a spike in storage requirements '
       'can result in permanently increased storage costs for your instance. '
       'However, if an instance runs out of available space, it can result in '
       'the instance going offline, dropping existing connections.'
   ).AddToParser(parser)
   parser.add_argument(
       '--replica-type',
       choices=['READ', 'FAILOVER'],
       help='The type of replica to create.')
   parser.add_argument(
       '--storage-size',
       type=arg_parsers.BinarySize(lower_bound='10GB', upper_bound='10230GB',
                                   suggested_binary_size_scales=['GB']),
       help='Amount of storage allocated to the instance. Must be an integer '
            'number of GB between 10GB and 10230GB inclusive.')
   parser.add_argument(
       '--maintenance-release-channel',
       choices={'production': 'Production updates are stable and recommended '
                              'for applications in production.',
                'preview': 'Preview updates release prior to production '
                           'updates. You may wish to use the preview channel '
                           'for dev/test applications so that you can preview '
                           'their compatibility with your application prior '
                           'to the production release.'},
       type=str.lower,
       help="Which channel's updates to apply during the maintenance window.")
   parser.add_argument(
       '--maintenance-window-day',
       choices=arg_parsers.DayOfWeek.DAYS,
       type=arg_parsers.DayOfWeek.Parse,
       help='Day of week for maintenance window, in UTC time zone.')
   parser.add_argument(
       '--maintenance-window-hour',
       type=arg_parsers.BoundedInt(lower_bound=0, upper_bound=23),
       help='Hour of day for maintenance window, in UTC time zone.')
Пример #6
0
def AddMemory(parser):
    parser.add_argument(
        '--memory',
        type=arg_parsers.BinarySize(),
        required=False,
        help=('A whole number value indicating how much memory is desired in '
              'the machine. A size unit should be provided (eg. 3072MiB or '
              '9GiB) - if no units are specified, GiB is assumed. Both --cpu '
              'and --memory must be specified if a custom machine type is '
              'desired, and the --tier flag must be omitted.'))
Пример #7
0
def AddDiskArgs(parser):
    """Adds arguments related to disks for instances and instance-templates."""

    boot_disk_device_name = parser.add_argument(
        '--boot-disk-device-name',
        help='The name the guest operating system will see the boot disk as.')
    boot_disk_device_name.detailed_help = """\
      The name the guest operating system will see for the boot disk as.  This
      option can only be specified if a new boot disk is being created (as
      opposed to mounting an existing persistent disk).
      """
    boot_disk_size = parser.add_argument(
        '--boot-disk-size',
        type=arg_parsers.BinarySize(lower_bound='10GB'),
        help='The size of the boot disk.')
    boot_disk_size.detailed_help = """\
      The size of the boot disk. This option can only be specified if a new
      boot disk is being created (as opposed to mounting an existing
      persistent disk). The value must be a whole number followed by a size
      unit of ``KB'' for kilobyte, ``MB'' for megabyte, ``GB'' for gigabyte,
      or ``TB'' for terabyte. For example, ``10GB'' will produce a 10 gigabyte
      disk. The minimum size a boot disk can have is 10 GB. Disk size must be a
      multiple of 1 GB.
      """

    boot_disk_type = parser.add_argument('--boot-disk-type',
                                         help='The type of the boot disk.')
    boot_disk_type.detailed_help = """\
      The type of the boot disk. This option can only be specified if a new boot
      disk is being created (as opposed to mounting an existing persistent
      disk). To get a list of available disk types, run
      `$ gcloud compute disk-types list`.
      """

    parser.add_argument(
        '--boot-disk-auto-delete',
        action='store_true',
        default=True,
        help='Automatically delete boot disks when their instances are deleted.'
    )

    disk = parser.add_argument(
        '--disk',
        type=arg_parsers.ArgDict(
            spec={
                'name': str,
                'mode': str,
                'boot': str,
                'device-name': str,
                'auto-delete': str,
            }),
        action=arg_parsers.FloatingListValuesCatcher(argparse._AppendAction),  # pylint:disable=protected-access
        help='Attaches persistent disks to the instances.',
        metavar='PROPERTY=VALUE')
    disk.detailed_help = """
Пример #8
0
def AddStorageSize(parser):
    parser.add_argument(
        '--storage-size',
        type=arg_parsers.BinarySize(lower_bound='10GB',
                                    upper_bound='30720GB',
                                    suggested_binary_size_scales=['GB']),
        help=(
            'Amount of storage allocated to the instance. Must be an integer '
            'number of GB. The default is 10GB. Information on storage '
            'limits can be found here: '
            'https://cloud.google.com/sql/docs/quotas#storage_limits'))
def AddMainVolumeSize(parser):
  parser.add_argument(
      '--main-volume-size',
      type=arg_parsers.BinarySize(
          suggested_binary_size_scales=['GB', 'GiB', 'TB', 'TiB'],
          default_unit='Gi'),
      help="""
        Size of the main volume. 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.
        """)
def AddConfigFlagsAlpha(worker_pools):
  """Add config flags."""
  worker_pools.add_argument(
      '--memory',
      type=arg_parsers.BinarySize(default_unit='GB'),
      hidden=True,
      help='Machine memory required to run a build.')
  worker_pools.add_argument(
      '--vcpu-count',
      type=float,
      hidden=True,
      help='Machine vCPU count required to run a build.')
def _CommonArgs(parser):
    Resize.DISKS_ARG.AddArgument(parser)
    parser.add_argument('--size',
                        required=True,
                        type=arg_parsers.BinarySize(lower_bound='1GB'),
                        help="""\
        Indicates the new size of the disks. The value must be a whole
        number followed by a size unit of ``KB'' for kilobyte, ``MB''
        for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For
        example, ``10GB'' will produce 10 gigabyte disks.  Disk size
        must be a multiple of 10 GB.
        """)
Пример #12
0
def AddDiskSizeFlag(parser):
    return parser.add_argument('--disk-size',
                               default='250GB',
                               type=arg_parsers.BinarySize(
                                   lower_bound='20GB',
                                   upper_bound='2000GB',
                                   suggested_binary_size_scales=['GB']),
                               help="""\
      Configures the root volume size of your Compute Engine VM (in GB). The
      minimum size is 20GB and the maximum is 2000GB. Specified value must be an
      integer multiple of Gigabytes.
      """)
Пример #13
0
def _Args(parser):
    """Register flags for this command.

  Args:
    parser: An argparse.ArgumentParser-like object. It is mocked out in order to
      capture some information, but behaves like an ArgumentParser.
  """
    flags.AddNodePoolNameArg(parser, 'The name of the node pool to create.')
    flags.AddNodePoolClusterFlag(parser,
                                 'The cluster to add the node pool to.')
    # Timeout in seconds for operation
    parser.add_argument('--timeout',
                        type=int,
                        default=1800,
                        hidden=True,
                        help='THIS ARGUMENT NEEDS HELP TEXT.')
    parser.add_argument(
        '--num-nodes',
        type=int,
        help='The number of nodes in the node pool in each of the '
        'cluster\'s zones.',
        default=3)
    flags.AddMachineTypeFlag(parser)
    parser.add_argument(
        '--disk-size',
        type=arg_parsers.BinarySize(lower_bound='10GB'),
        help='Size for node VM boot disks in GB. Defaults to 100GB.')
    flags.AddImageTypeFlag(parser, 'node pool')
    flags.AddImageFlag(parser, hidden=True)
    flags.AddImageProjectFlag(parser, hidden=True)
    flags.AddImageFamilyFlag(parser, hidden=True)
    flags.AddNodeLabelsFlag(parser, for_node_pool=True)
    flags.AddTagsFlag(
        parser, """\
Applies the given Compute Engine tags (comma separated) on all nodes in the new
node-pool. Example:

  $ {command} node-pool-1 --cluster=example-cluster --tags=tag1,tag2

New nodes, including ones created by resize or recreate, will have these tags
on the Compute Engine API instance object and can be used in firewall rules.
See https://cloud.google.com/sdk/gcloud/reference/compute/firewall-rules/create
for examples.
""")
    parser.display_info.AddFormat(util.NODEPOOLS_FORMAT)
    flags.AddNodeVersionFlag(parser)
    flags.AddDiskTypeFlag(parser)
    flags.AddMetadataFlags(parser)
    flags.AddShieldedInstanceFlags(parser)
    flags.AddNetworkConfigFlags(parser)
    flags.AddThreadsPerCore(parser)
def ParseMemoryStrToNumBytes(binary_size):
    """Parse binary size to number of bytes.

  Args:
    binary_size: str, memory with size suffix

  Returns:
    num_bytes: int, the number of bytes
  """

    binary_size_parser = arg_parsers.BinarySize(
        suggested_binary_size_scales=['KB', 'MB', 'MiB', 'GB', 'GiB'],
        default_unit='MB')
    return binary_size_parser(binary_size)
Пример #15
0
def AddWorkerpoolArgs(parser, update=False):
    """Set up all the argparse flags for creating or updating a workerpool.

  Args:
    parser: An argparse.ArgumentParser-like object.
    update: If true, use the version of the flags for updating a workerpool.
      Otherwise, use the version for creating a workerpool.

  Returns:
    The parser argument with workerpool flags added in.
  """
    verb = 'update' if update else 'create'
    file_or_flags = parser.add_mutually_exclusive_group(required=True)
    file_or_flags.add_argument(
        '--config-from-file',
        help=(_UPDATE_FILE_DESC if update else _CREATE_FILE_DESC),
    )
    flags = file_or_flags.add_argument_group(
        'Command-line flags to configure the WorkerPool:')
    flags.add_argument(
        'WORKER_POOL',
        help='The WorkerPool to %s.' % verb,
    )
    flags.add_argument('--region',
                       help='The Cloud region where the WorkerPool is.')
    flags.add_argument('--peered-network',
                       help="""\
Network which workers are peered to.

`default` network is used if empty string.
""")
    worker_flags = flags.add_argument_group(
        'Configuration to be used for creating workers in the WorkerPool:')
    worker_flags.add_argument('--worker-machine-type',
                              help="""\
Machine Type of the worker, such as n1-standard-1.

See https://cloud.google.com/compute/docs/machine-types.

If left blank, Cloud Build will use a standard unspecified machine to create the
worker pool.
""")
    worker_flags.add_argument('--worker-disk-size',
                              type=arg_parsers.BinarySize(lower_bound='100GB'),
                              help="""\
Size of the disk attached to the worker.

If not given, Cloud Build will use a standard disk size.
""")
    return parser
Пример #16
0
def AddFunctionMemoryFlag(parser):
    """Add flag for specifying function memory to the parser."""
    parser.add_argument(
        '--memory',
        type=arg_parsers.BinarySize(
            suggested_binary_size_scales=['KB', 'MB', 'MiB', 'GB', 'GiB'],
            default_unit='MB'),
        help="""\
      Limit on the amount of memory the function can use.

      Allowed values are: 128MB, 256MB, 512MB, 1024MB, and 2048MB. By default,
      a new function is limited to 256MB of memory. When deploying an update to
      an existing function, the function will keep its old memory limit unless
      you specify this flag.""")
Пример #17
0
def _CommonArgs(parser, source_snapshot_arg):
    """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_snapshot_arg)

    csek_utils.AddCsekKeyArgs(parser)
    labels_util.AddCreateLabelsFlags(parser)
Пример #18
0
def AddResourcesFlag(parser):
    """Add --resources flag in `commitments create`."""
    resources_help = """\
Resources to be included in the commitment, the ratio between number of vCPU cores and memory must conform to limits described at:
https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type#specifications.
*memory*::: The size of the memory, should include units (e.g. 3072MB or 9GB). If no units are specified, GB is assumed.
*vcpu*::: The number of the vCPU cores."""
    parser.add_argument('--resources',
                        required=True,
                        help=resources_help,
                        type=arg_parsers.ArgDict(
                            spec={
                                'vcpu': int,
                                'memory': arg_parsers.BinarySize()
                            },
                            required_keys=['vcpu', 'memory']))
Пример #19
0
def AddMemory(parser):
    """Adds a --memory flag to parser.

  Args:
    parser: argparse.Parser: Parser object for command line inputs.
  """
    parser.add_argument(
        '--memory',
        required=False,
        type=arg_parsers.BinarySize(),
        help=(
            'Whole number value indicating how much memory is desired in '
            'the machine. A size unit should be provided (eg. 3072MiB or '
            '9GiB) - if no units are specified, GiB is assumed. Both `--cpu` '
            'and `--memory` must be specified if a custom machine type is '
            'desired, and the `--tier` flag must be omitted.'))
Пример #20
0
def AddCustomMachineTypeArgs(parser):
  """Adds arguments related to custom machine types for instances."""
  custom_cpu = parser.add_argument(
      '--custom-cpu',
      type=int,
      help='Number of CPUs desired in the instance for a custom machine type.')
  custom_cpu.detailed_help = """\
      A whole number value indicating how many cores are desired in the custom
      machine type. Both --custom-cpu and --custom-memory must be specified if
      a custom machine type is desired, and the --machine-type flag must be
      omitted.
      """
  custom_memory = parser.add_argument(
      '--custom-memory',
      type=arg_parsers.BinarySize(),
      help='Amount of memory desired in the instance for a custom machine type '
      '(set units, default GiB).')
  custom_memory.detailed_help = """\
Пример #21
0
def _FunctionArgs(parser):
    """Add arguments specyfying functions behavior to the parser."""
    parser.add_argument('name',
                        help='Intended name of the new function.',
                        type=util.ValidateFunctionNameOrRaise)
    parser.add_argument(
        '--memory',
        type=arg_parsers.BinarySize(
            suggested_binary_size_scales=['KB', 'MB', 'MiB', 'GB', 'GiB']),
        help="""\
      The amount of memory allocated to your function.

      Allowed values are: 128MB, 256MB, 512MB, 1024MB, and 2048MB.
      """)
    parser.add_argument(
        '--timeout',
        help=('The function execution timeout, e.g. 30s for 30 seconds. '
              'Defaults to 60 seconds.'),
        type=arg_parsers.Duration(lower_bound='1s'))
Пример #22
0
def AddCustomMachineTypeArgs(parser):
    """Adds arguments related to custom machine types for instances."""
    parser.add_argument('--custom-cpu',
                        type=int,
                        help="""\
      A whole number value indicating how many cores are desired in the custom
      machine type. Both --custom-cpu and --custom-memory must be specified if
      a custom machine type is desired, and the --machine-type flag must be
      omitted.
      """)
    parser.add_argument('--custom-memory',
                        type=arg_parsers.BinarySize(),
                        help="""\
      A whole number value indicating how much memory is desired in the custom
      machine type. A size unit should be provided (eg. 3072MiB or 9GiB) - if
      no units are specified, GiB is assumed. Both --custom-cpu and
      --custom-memory must be specified if a custom machine type is desired,
      and the --machine-type flag must be omitted.
      """)
Пример #23
0
def AddCreateDiskArgs(parser):
  """Adds create-disk argument for instances and instance-templates."""

  create_disk = parser.add_argument(
      '--create-disk',
      type=arg_parsers.ArgDict(spec={
          'name': str,
          'mode': str,
          'image': str,
          'image-family': str,
          'image-project': str,
          'size': arg_parsers.BinarySize(lower_bound='10GB'),
          'type': str,
          'device-name': str,
          'auto-delete': str,
      }),
      action='append',
      help='Creates and attaches persistent disks to the instances.',
      metavar='PROPERTY=VALUE')
  create_disk.detailed_help = """
Пример #24
0
def AddCreateFlags(parser):
  """Add general arguments for `commitments create` flag."""
  parser.add_argument('--plan',
                      required=True,
                      choices=VALID_PLANS,
                      help=('Duration of the commitment.'))
  resources_help = """\
  Resources to be included in the commitment commitment:
  * MEMORY should include unit (eg. 3072MB or 9GB). If no units are specified,
    GB is assumed.
  * VCPU is number of committed cores.
  Ratio between number of VCPU cores and memory must conform to limits
  described on:
  https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type"""
  parser.add_argument('--resources',
                      required=True,
                      help=resources_help,
                      metavar='RESOURCE=COMMITMENT',
                      type=arg_parsers.ArgDict(spec={
                          'VCPU': int,
                          'MEMORY': arg_parsers.BinarySize(),
                      }))
Пример #25
0
def _CommonArgs(parser):
  """Add arguments used for parsing in all command tracks."""
  parser.add_argument(
      '--description',
      help=(
          'An optional, textual description for the disks being created.'))

  size = parser.add_argument(
      '--size',
      type=arg_parsers.BinarySize(lower_bound='1GB'),
      help='Indicates the size of the disks.')
  size.detailed_help = """\
      Indicates the size of the disks. The value must be a whole
      number followed by a size unit of ``KB'' for kilobyte, ``MB''
      for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For
      example, ``10GB'' will produce 10 gigabyte disks.  Disk size
      must be a multiple of 10 GB.
      """

  parser.add_argument(
      'names',
      metavar='NAME',
      nargs='+',
      help='The names of the disks to create.')

  disk_type = parser.add_argument(
      '--type',
      help='Specifies the type of disk to create.')
  disk_type.detailed_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.
      """

  utils.AddZoneFlag(
      parser,
      resource_type='disks',
      operation_type='create')
Пример #26
0
  def Args(cls, parser):
    flags.MakeCommitmentArg(False).AddArgument(parser)
    parser.add_argument('--plan',
                        required=True,
                        help=('Duration of the commitment. Can be `12-months` '
                              'or `36-months`.'))
    resources_help = """\
    Resources to be included in the commitment commitment:
    * MEMORY should include unit (eg. 3072MiB or 9GiB). If no units are
      specified, GiB is assumed.
    * VCPU is number of commited cores.
    Ratio between number of VCPU cores and memory must conform to limits
    described on:
    https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type"""

    parser.add_argument('--resources',
                        required=True,
                        help=resources_help,
                        metavar='RESOURCE=COMMITMENT',
                        type=arg_parsers.ArgDict(spec={
                            'VCPU': int,
                            'MEMORY': arg_parsers.BinarySize(),
                        }))
    def Args(parser):
        parser.add_argument('disk_names',
                            metavar='DISK_NAME',
                            nargs='+',
                            completion_resource='compute.disks',
                            help='The names of the disks to resize.')

        size = parser.add_argument(
            '--size',
            required=True,
            type=arg_parsers.BinarySize(lower_bound='1GB'),
            help='Indicates the new size of the disks.')
        size.detailed_help = """\
        Indicates the new size of the disks. The value must be a whole
        number followed by a size unit of ``KB'' for kilobyte, ``MB''
        for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For
        example, ``10GB'' will produce 10 gigabyte disks.  Disk size
        must be a multiple of 10 GB.
        """

        utils.AddZoneFlag(parser,
                          resource_type='disks',
                          operation_type='be resized')
Пример #28
0
def AddResourcesArgGroup(parser):
  """Add the argument group for ResourceCommitment support in commitment."""
  resources_group = parser.add_group(
      'Manage the commitment for particular resources.', required=True)

  resources_help = """\
Resources to be included in the commitment, the ratio between number of vCPU cores and memory must conform to limits described at:
https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type#specifications.
*memory*::: The size of the memory, should include units (e.g. 3072MB or 9GB). If no units are specified, GB is assumed.
*vcpu*::: The number of the vCPU cores.
*local-ssd*::: The size of local SSD.
"""

  resources_group.add_argument(
      '--resources',
      help=resources_help,
      required=True,
      type=arg_parsers.ArgDict(
          spec={
              'vcpu': int,
              'local-ssd': int,
              'memory': arg_parsers.BinarySize()
          },
          required_keys=['vcpu', 'memory']))
  accelerator_help = """\
Manage the configuration of the type and number of accelerator cards to include in the commitment.
*count*::: The number of accelerators to include.
*type*::: The specific type (e.g. nvidia-tesla-k80 for NVIDIA Tesla K80) of the accelerator. Use `gcloud compute accelerator-types list` to learn about all available accelerator types.
"""
  resources_group.add_argument(
      '--resources-accelerator',
      help=accelerator_help,
      type=arg_parsers.ArgDict(spec={
          'count': int,
          'type': str
      }))
Пример #29
0
def _FunctionArgs(parser):
    """Add arguments specyfying functions behavior to the parser."""
    parser.add_argument(
        'name',
        help='Name of the function to deploy.',
        type=util.ValidateFunctionNameOrRaise,
    )
    parser.add_argument(
        '--memory',
        type=arg_parsers.BinarySize(
            suggested_binary_size_scales=['KB', 'MB', 'MiB', 'GB', 'GiB'],
            default_unit='MB'),
        help="""\
      Limit on the amount of memory the function can use.

      Allowed values are: 128MB, 256MB, 512MB, 1024MB, and 2048MB. By default,
      a new function is limited to 256MB of memory. When deploying an update to
      an existing function, the function will keep its old memory limit unless
      you specify this flag.""")
    parser.add_argument('--timeout',
                        help="""\
      The function execution timeout, e.g. 30s for 30 seconds. Defaults to
      original value for existing function or 60 seconds for new functions.
      Cannot be more than 540s.""",
                        type=arg_parsers.Duration(lower_bound='1s',
                                                  upper_bound='540s'))
    parser.add_argument(
        '--retry',
        help=('If specified, then the function will be retried in case of a '
              'failure.'),
        action='store_true',
    )
    labels_util.AddUpdateLabelsFlags(
        parser,
        extra_update_message=' ' + _NO_LABELS_STARTING_WITH_DEPLOY_MESSAGE,
        extra_remove_message=' ' + _NO_LABELS_STARTING_WITH_DEPLOY_MESSAGE)
Пример #30
0
def _CommonArgs(parser, source_snapshot_arg):
  """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="""\
        Indicates the 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.
        """)

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

  _SourceArgs(parser, source_snapshot_arg)

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