コード例 #1
0
    def Args(parser):
        """Register parser args."""
        metadata_utils.AddMetadataArgs(parser)
        instances_flags.AddDiskArgs(parser, True)
        instances_flags.AddCreateDiskArgs(parser)
        instances_flags.AddLocalSsdArgsWithSize(parser)
        instances_flags.AddCanIpForwardArgs(parser)
        instances_flags.AddAddressArgs(parser, instances=True)
        instances_flags.AddMachineTypeArgs(parser)
        instances_flags.AddMaintenancePolicyArgs(parser)
        instances_flags.AddNoRestartOnFailureArgs(parser)
        instances_flags.AddPreemptibleVmArgs(parser)
        instances_flags.AddServiceAccountAndScopeArgs(parser, False)
        instances_flags.AddTagsArgs(parser)
        instances_flags.AddCustomMachineTypeArgs(parser)
        instances_flags.AddExtendedMachineTypeArgs(parser)
        instances_flags.AddNetworkArgs(parser)
        instances_flags.AddPrivateNetworkIpArgs(parser)
        instances_flags.AddDockerArgs(parser)
        instances_flags.AddPublicDnsArgs(parser, instance=True)
        instances_flags.AddNetworkTierArgs(parser, instance=True)
        instances_flags.AddMinCpuPlatformArgs(parser)
        labels_util.AddCreateLabelsFlags(parser)

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

        instances_flags.INSTANCES_ARG.AddArgument(parser)
コード例 #2
0
ファイル: create.py プロジェクト: talentdeveloper/casino_bot
    def Args(parser):
        """Registers flags for this command."""

        parser.add_argument('snapshot',
                            nargs='+',
                            help='One or more snapshot names to create.')

        parser.add_argument(
            '--subscription',
            required=True,
            help=
            ('The subscription whose backlog the snapshot retains. '
             ' Specifically, the created snapshot is guaranteed to retain a)'
             ' The existing backlog on the subscription, i.e., the set of'
             ' messages in the subscription that are unacknowledged upon the'
             ' successful completion of the create snapshot request, b) Any'
             ' messages published to the subscription\'s topic following the'
             ' successful creation of the snapshot.'))

        parser.add_argument(
            '--subscription-project',
            default='',
            help=(
                'The name of the project the provided subscription belongs to.'
                ' If not set, it defaults to the currently selected'
                ' cloud project.'))

        labels_util.AddCreateLabelsFlags(parser)
コード例 #3
0
    def Args(parser):
        """Default argument specification."""

        labels_util.AddCreateLabelsFlags(parser)
        type_ = arg_parsers.RegexpValidator(r'[a-z][a-z0-9-]{5,29}',
                                            ID_DESCRIPTION)
        parser.add_argument(
            'id',
            metavar='PROJECT_ID',
            type=type_,
            nargs='?',
            help='ID for the project you want to create.\n\n{0}'.format(
                ID_DESCRIPTION))
        parser.add_argument('--name',
                            help='Name for the project you want to create. '
                            'If not specified, will use project id as name.')
        parser.add_argument(
            '--enable-cloud-apis',
            action='store_true',
            default=True,
            help='Enable cloudapis.googleapis.com during creation.')
        parser.add_argument(
            '--set-as-default',
            action='store_true',
            default=False,
            help='Set newly created project as [core.project] property.')
        flags.OrganizationIdFlag('to use as a parent').AddToParser(parser)
        flags.FolderIdFlag('to use as a parent').AddToParser(parser)
コード例 #4
0
def _Args(parser, release_track):
    """Set Args based on Release Track."""
    # GA Args
    parser.display_info.AddFormat(flags.LIST_FORMAT)

    sources_group = parser.add_mutually_exclusive_group(required=True)
    flags.AddCommonArgs(parser)
    flags.AddCommonSourcesArgs(parser, sources_group)

    Create.DISK_IMAGE_ARG = flags.MakeDiskImageArg()
    Create.DISK_IMAGE_ARG.AddArgument(parser, operation_type='create')
    csek_utils.AddCsekKeyArgs(parser, resource_type='image')

    labels_util.AddCreateLabelsFlags(parser)
    flags.MakeForceArg().AddToParser(parser)
    flags.AddCloningImagesArgs(parser, sources_group)

    # Alpha and Beta Args
    if release_track in (base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA):
        # Deprecated as of Aug 2017.
        flags.MakeForceCreateArg().AddToParser(parser)

    # Alpha Args
    if release_track == base.ReleaseTrack.ALPHA:
        flags.AddCreatingImageFromSnapshotArgs(parser, sources_group)
コード例 #5
0
    def Args(parser):
        parser.add_argument('--max-failures-per-hour',
                            type=int,
                            help=argparse.SUPPRESS)

        JobSubmitter.Args(parser)
        labels_util.AddCreateLabelsFlags(parser)
コード例 #6
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 ``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('--type',
                        completion_resource='compute.diskTypes',
                        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.
      """)

    _SourceArgs(parser, source_snapshot_arg)

    csek_utils.AddCsekKeyArgs(parser)
    labels_util.AddCreateLabelsFlags(parser)
コード例 #7
0
    def Args(parser, version=base.ReleaseTrack.GA):
        """Args is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go
          on the command line after this command. Positional arguments are
          allowed.
      version: The version this tool is running as. base.ReleaseTrack.GA
          is the default.
    """
        flags.AddAsyncFlag(parser)
        flags.AddDeploymentNameFlag(parser)
        flags.AddPropertiesFlag(parser)

        if version in [base.ReleaseTrack.ALPHA]:
            labels_util.AddCreateLabelsFlags(parser)
        parser.add_argument(
            '--description',
            help='Optional description of the deployment to insert.',
            dest='description')

        parser.add_argument(
            '--config',
            help='Filename of config which specifies resources to deploy.',
            dest='config',
            required=True)

        parser.add_argument(
            '--preview',
            help=
            'Preview the requested create without actually instantiating the '
            'underlying resources. (default=False)',
            dest='preview',
            default=False,
            action='store_true')
コード例 #8
0
 def Args(parser):
   """Register flags for this command."""
   labels_util.AddCreateLabelsFlags(parser)
   parser.add_argument(
       '--cluster',
       required=True,
       help='The Dataproc cluster to submit the job to.')
コード例 #9
0
    def Args(parser):
        """Register parser args."""
        parser.display_info.AddFormat(instances_flags.DEFAULT_LIST_FORMAT)
        metadata_utils.AddMetadataArgs(parser)
        instances_flags.AddDiskArgs(parser, True)
        instances_flags.AddCreateDiskArgs(parser)
        instances_flags.AddLocalSsdArgsWithSize(parser)
        instances_flags.AddCanIpForwardArgs(parser)
        instances_flags.AddAddressArgs(parser, instances=True)
        instances_flags.AddMachineTypeArgs(parser)
        instances_flags.AddMaintenancePolicyArgs(parser)
        instances_flags.AddNoRestartOnFailureArgs(parser)
        instances_flags.AddPreemptibleVmArgs(parser)
        instances_flags.AddServiceAccountAndScopeArgs(parser, False)
        instances_flags.AddTagsArgs(parser)
        instances_flags.AddCustomMachineTypeArgs(parser)
        instances_flags.AddNetworkArgs(parser)
        instances_flags.AddPrivateNetworkIpArgs(parser)
        instances_flags.AddDockerArgs(parser)
        instances_flags.AddPublicDnsArgs(parser, instance=True)
        instances_flags.AddNetworkTierArgs(parser, instance=True)
        instances_flags.AddMinCpuPlatformArgs(parser, base.ReleaseTrack.ALPHA)
        labels_util.AddCreateLabelsFlags(parser)

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

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

        CreateFromContainer.SOURCE_INSTANCE_TEMPLATE = (
            instances_flags.MakeSourceInstanceTemplateArg())
        CreateFromContainer.SOURCE_INSTANCE_TEMPLATE.AddArgument(parser)
コード例 #10
0
 def Args(parser):
     _CommonArgs(parser)
     labels_util.AddCreateLabelsFlags(parser)
     num_masters = parser.add_argument(
         '--num-masters',
         type=int,
         help='The number of master nodes in the cluster.')
     num_masters.detailed_help = """\
コード例 #11
0
    def Args(parser):
        flags.GetPipelineInputPairFlag().AddToParser(parser)
        flags.GetPipelineOutputPathFlag().AddToParser(parser)
        flags.GetPipelineSampleNameFlag().AddToParser(parser)

        labels_util.AddCreateLabelsFlags(parser)

        flags.GetPipelineLoggingFlag().AddToParser(parser)
        flags.GetPipelineZonesFlag().AddToParser(parser)
コード例 #12
0
 def Args(parser):
     flags.AddCryptoKeyArgument(parser, 'to create')
     flags.AddRotationPeriodFlag(parser)
     flags.AddNextRotationTimeFlag(parser)
     labels_util.AddCreateLabelsFlags(parser)
     parser.add_argument('--purpose',
                         choices=PURPOSE_MAP.keys(),
                         required=True,
                         help='The "purpose" of the key.')
コード例 #13
0
ファイル: create.py プロジェクト: talentdeveloper/casino_bot
def _CommonArgs(parser,
                release_track,
                support_public_dns,
                support_public_ptr,
                support_network_tier,
                enable_regional=False,
                support_local_ssd_size=False,
                enable_kms=False):
  """Register parser args common to all tracks."""
  metadata_utils.AddMetadataArgs(parser)
  instances_flags.AddDiskArgs(parser, enable_regional, enable_kms=enable_kms)
  if release_track in [base.ReleaseTrack.ALPHA]:
    instances_flags.AddCreateDiskArgs(parser, enable_kms=enable_kms)
  if support_local_ssd_size:
    instances_flags.AddLocalSsdArgsWithSize(parser)
  else:
    instances_flags.AddLocalSsdArgs(parser)
  instances_flags.AddCanIpForwardArgs(parser)
  instances_flags.AddAddressArgs(
      parser, instances=True,
      support_network_tier=support_network_tier)
  instances_flags.AddAcceleratorArgs(parser)
  instances_flags.AddMachineTypeArgs(parser)
  deprecate_maintenance_policy = release_track in [base.ReleaseTrack.ALPHA]
  instances_flags.AddMaintenancePolicyArgs(parser, deprecate_maintenance_policy)
  instances_flags.AddNoRestartOnFailureArgs(parser)
  instances_flags.AddPreemptibleVmArgs(parser)
  instances_flags.AddServiceAccountAndScopeArgs(parser, False)
  instances_flags.AddTagsArgs(parser)
  instances_flags.AddCustomMachineTypeArgs(parser)
  instances_flags.AddNetworkArgs(parser)
  instances_flags.AddPrivateNetworkIpArgs(parser)
  instances_flags.AddImageArgs(parser)
  instances_flags.AddDeletionProtectionFlag(parser)
  if support_public_dns:
    instances_flags.AddPublicDnsArgs(parser, instance=True)
  if support_public_ptr:
    instances_flags.AddPublicPtrArgs(parser, instance=True)
  if support_network_tier:
    instances_flags.AddNetworkTierArgs(parser, instance=True)

  labels_util.AddCreateLabelsFlags(parser)
  instances_flags.AddMinCpuPlatformArgs(parser, release_track)

  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)
コード例 #14
0
def _CommonArgs(parser,
                multiple_network_interface_cards,
                release_track,
                support_alias_ip_ranges,
                support_public_dns,
                support_network_tier,
                enable_regional=False,
                support_local_ssd_size=False):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser, enable_regional)
    if release_track in [base.ReleaseTrack.ALPHA]:
        instances_flags.AddCreateDiskArgs(parser)
    if release_track in [base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA]:
        instances_flags.AddExtendedMachineTypeArgs(parser)
    if support_local_ssd_size:
        instances_flags.AddLocalSsdArgsWithSize(parser)
    else:
        instances_flags.AddLocalSsdArgs(parser)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(
        parser,
        instances=True,
        multiple_network_interface_cards=multiple_network_interface_cards,
        support_alias_ip_ranges=support_alias_ip_ranges,
        support_network_tier=support_network_tier)
    instances_flags.AddAcceleratorArgs(parser)
    instances_flags.AddMachineTypeArgs(parser)
    instances_flags.AddMaintenancePolicyArgs(parser)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(parser, False)
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddNetworkArgs(parser)
    instances_flags.AddPrivateNetworkIpArgs(parser)
    instances_flags.AddImageArgs(parser)
    if support_public_dns:
        instances_flags.AddPublicDnsArgs(parser, instance=True)
    if support_network_tier:
        instances_flags.AddNetworkTierArgs(parser, instance=True)

    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)

    parser.display_info.AddFormat(
        resource_registry.RESOURCE_REGISTRY['compute.instances'].list_format)
コード例 #15
0
ファイル: create.py プロジェクト: bopopescu/nodeserver
  def Args(parser):
    Create.disks_arg = disks_flags.MakeDiskArgZonalOrRegional(plural=True)
    parser.add_argument(
        '--replica-zones',
        type=arg_parsers.ArgList(),
        metavar='ZONE1, ZONE2',
        help=('The zones regional disk will be replicated to. Required when '
              'creating regional disk.'),
        hidden=True)

    _CommonArgs(parser, disks_flags.SOURCE_SNAPSHOT_ARG)
    labels_util.AddCreateLabelsFlags(parser)
コード例 #16
0
ファイル: create.py プロジェクト: rach24/Quiz-Web-game
def _CommonArgs(parser,
                release_track,
                support_source_instance,
                support_create_disk=False,
                support_network_tier=False,
                support_local_ssd_size=False,
                support_labels=False):
    """Adding arguments applicable for creating instance templates."""
    parser.display_info.AddFormat(instance_templates_flags.DEFAULT_LIST_FORMAT)
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser)
    if support_create_disk:
        instances_flags.AddCreateDiskArgs(parser)
    if support_local_ssd_size:
        instances_flags.AddLocalSsdArgsWithSize(parser)
    else:
        instances_flags.AddLocalSsdArgs(parser)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(parser,
                                   instances=False,
                                   support_network_tier=support_network_tier)
    instances_flags.AddAcceleratorArgs(parser)
    instances_flags.AddMachineTypeArgs(parser)
    deprecate_maintenance_policy = release_track in [base.ReleaseTrack.ALPHA]
    instances_flags.AddMaintenancePolicyArgs(parser,
                                             deprecate_maintenance_policy)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(parser, False)
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddImageArgs(parser)
    instances_flags.AddNetworkArgs(parser)

    if support_network_tier:
        instances_flags.AddNetworkTierArgs(parser, instance=True)

    if support_labels:
        labels_util.AddCreateLabelsFlags(parser)

    flags.AddRegionFlag(parser,
                        resource_type='subnetwork',
                        operation_type='attach')

    parser.add_argument(
        '--description',
        help='Specifies a textual description for the instance template.')

    Create.InstanceTemplateArg = (
        instance_templates_flags.MakeInstanceTemplateArg())
    Create.InstanceTemplateArg.AddArgument(parser, operation_type='create')
    if support_source_instance:
        instance_templates_flags.MakeSourceInstanceArg().AddArgument(parser)
コード例 #17
0
    def Args(parser, version=base.ReleaseTrack.GA):
        """Args is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go
          on the command line after this command. Positional arguments are
          allowed.
      version: The version this tool is running as. base.ReleaseTrack.GA
          is the default.
    """
        group = parser.add_mutually_exclusive_group()

        flags.AddAsyncFlag(group)
        flags.AddDeploymentNameFlag(parser)
        flags.AddPropertiesFlag(parser)

        if version in [base.ReleaseTrack.ALPHA]:
            labels_util.AddCreateLabelsFlags(parser)

            group.add_argument(
                '--automatic-rollback-on-error',
                help=
                'If the create request results in a deployment with resource '
                'errors, delete that deployment immediately after creation. '
                '(default=False)',
                dest='automatic_rollback',
                default=False,
                action='store_true')

        parser.add_argument(
            '--description',
            help='Optional description of the deployment to insert.',
            dest='description')

        parser.add_argument(
            '--config',
            help='Filename of config that specifies resources to deploy. '
            'More information is available at '
            'https://cloud.google.com/deployment-manager/docs/configuration/.',
            dest='config',
            required=True)

        parser.add_argument(
            '--preview',
            help=
            'Preview the requested create without actually instantiating the '
            'underlying resources. (default=False)',
            dest='preview',
            default=False,
            action='store_true')

        parser.display_info.AddFormat(flags.RESOURCES_AND_OUTPUTS_FORMAT)
コード例 #18
0
 def Args(parser):
     """Register flags for this command."""
     labels_util.AddCreateLabelsFlags(parser)
     parser.add_argument(
         '--max-failures-per-hour',
         type=int,
         help=(
             'Specifies maximum number of times a job can be restarted in '
             'event of failure. Expressed as a per-hour rate. '
             'Default is 0 (no failure retries).'))
     parser.add_argument('--cluster',
                         required=True,
                         help='The Dataproc cluster to submit the job to.')
コード例 #19
0
ファイル: create.py プロジェクト: TobiahRex/Wingman
 def Args(parser):
     labels_util.AddCreateLabelsFlags(parser)
     parser.add_argument('id',
                         metavar='PROJECT_ID',
                         help='ID for the project you want to create.')
     parser.add_argument('--name',
                         help='Name for the project you want to create. '
                         'If not specified, will use project id as name.')
     parser.add_argument(
         '--enable-cloud-apis',
         action='store_true',
         default=True,
         help='Enable cloudapis.googleapis.com during creation.')
コード例 #20
0
def _AddCreateArgs(parser):
    """Add common arguments for `versions create` command."""
    flags.GetModelName(positional=False, required=True).AddToParser(parser)
    flags.VERSION_NAME.AddToParser(parser)
    base.Argument('--origin',
                  help="""\
          Location of ```model/``` "directory" (as output by
          https://www.tensorflow.org/versions/r0.12/api_docs/python/state_ops.html#Saver).

          This overrides `deploymentUri` in the `--config` file. If this flag is
          not passed, `deploymentUri` *must* be specified in the file from
          `--config`.

          Can be a Google Cloud Storage (`gs://`) path or local file path (no
          prefix). In the latter case the files will be uploaded to Google Cloud
          Storage and a `--staging-bucket` argument is required.
      """).AddToParser(parser)
    flags.RUNTIME_VERSION.AddToParser(parser)
    base.ASYNC_FLAG.AddToParser(parser)
    flags.STAGING_BUCKET.AddToParser(parser)
    base.Argument('--config',
                  help="""\
          Path to a YAML configuration file containing configuration parameters
          for the
          [Version](https://cloud.google.com/ml/reference/rest/v1/projects.models.versions)
          to create.

          The file is in YAML format. Note that not all attributes of a Version
          are configurable; available attributes (with example values) are:

              description: A free-form description of the version.
              deploymentUri: gs://path/to/source
              runtimeVersion: '1.0'
              manualScaling:
                nodes: 10  # The number of nodes to allocate for this model.
              autoScaling:
                minNodes: 0  # The minimum number of nodes to allocate for this model.
              labels:
                user-defined-key: user-defined-value

          The name of the version must always be specified via the required
          VERSION argument.

          Only one of manualScaling or autoScaling must be specified. If both
          are specified in same yaml file an error will be returned.

          If an option is specified both in the configuration file and via
          command line arguments, the command line arguments override the
          configuration file.
      """).AddToParser(parser)
    labels_util.AddCreateLabelsFlags(parser)
コード例 #21
0
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go
          on the command line after this command. Positional arguments are
          allowed.
    """
        flags.AddAsyncFlag(parser)
        type_providers.AddTypeProviderNameFlag(parser)
        type_providers.AddApiOptionsFileFlag(parser)
        type_providers.AddDescriptionFlag(parser)
        type_providers.AddDescriptorUrlFlag(parser)
        labels_util.AddCreateLabelsFlags(parser)
コード例 #22
0
  def Args(parser):
    """Args is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go
          on the command line after this command. Positional arguments are
          allowed.
    """
    flags.AddAsyncFlag(parser)
    composite_types.AddCompositeTypeNameFlag(parser)
    composite_types.AddTemplateFlag(parser)
    composite_types.AddDescriptionFlag(parser)
    composite_types.AddStatusFlag(parser)
    labels_util.AddCreateLabelsFlags(parser)
コード例 #23
0
def _AddCreateArgs(parser):
    """Get arguments for the `ml-engine models create` command."""
    flags.GetModelName().AddToParser(parser)
    parser.add_argument('--regions',
                        metavar='REGION',
                        type=arg_parsers.ArgList(min_length=1),
                        help="""\
The Google Cloud region where the model will be deployed (currently only a
single region is supported).

Will soon be required, but defaults to 'us-central1' for now.
""")
    parser.add_argument(
        '--enable-logging',
        action='store_true',
        help=('If set, enables StackDriver Logging for online prediction.'))
    labels_util.AddCreateLabelsFlags(parser)
コード例 #24
0
def AddWorkflowTemplatesArgs(parser):
    """Register flags for this command."""
    labels_util.AddCreateLabelsFlags(parser)
    parser.add_argument('--workflow-template',
                        required=True,
                        help='The dataproc workflow template ID.')

    parser.add_argument(
        '--step-id',
        required=True,
        type=str,
        help='The step ID of the job in the workflow template.')

    parser.add_argument(
        '--start-after',
        metavar='STEP_ID',
        type=arg_parsers.ArgList(element_type=str, min_length=1),
        help='(Optional) List of step IDs to start this job after.')
コード例 #25
0
 def Args(parser):
   labels_util.AddCreateLabelsFlags(parser)
   type_ = arg_parsers.RegexpValidator(r'[a-z][a-z0-9-]{5,29}', ID_DESCRIPTION)
   project_id = parser.add_argument(
       'id',
       metavar='PROJECT_ID',
       type=type_,
       help='ID for the project you want to create.')
   project_id.detailed_help = ('ID for the project you want to create.'
                               '\n\n{0}'.format(ID_DESCRIPTION))
   parser.add_argument(
       '--name',
       help='Name for the project you want to create. '
       'If not specified, will use project id as name.')
   parser.add_argument(
       '--enable-cloud-apis',
       action='store_true',
       default=True,
       help='Enable cloudapis.googleapis.com during creation.')
def _Args(parser, release_track):
    """Add flags shared by all release tracks."""
    parser.display_info.AddFormat(instances_flags.DEFAULT_LIST_FORMAT)
    metadata_utils.AddMetadataArgs(parser)
    instances_flags.AddDiskArgs(parser, True)
    instances_flags.AddCreateDiskArgs(parser)
    instances_flags.AddLocalSsdArgsWithSize(parser)
    instances_flags.AddCanIpForwardArgs(parser)
    instances_flags.AddAddressArgs(parser, instances=True)
    instances_flags.AddMachineTypeArgs(parser)
    deprecate_maintenance_policy = release_track in [base.ReleaseTrack.ALPHA]
    instances_flags.AddMaintenancePolicyArgs(parser,
                                             deprecate_maintenance_policy)
    instances_flags.AddNoRestartOnFailureArgs(parser)
    instances_flags.AddPreemptibleVmArgs(parser)
    instances_flags.AddServiceAccountAndScopeArgs(parser, False)
    instances_flags.AddTagsArgs(parser)
    instances_flags.AddCustomMachineTypeArgs(parser)
    instances_flags.AddNetworkArgs(parser)
    instances_flags.AddPrivateNetworkIpArgs(parser)
    instances_flags.AddKonletArgs(parser)
    instances_flags.AddPublicDnsArgs(parser, instance=True)
    instances_flags.AddPublicPtrArgs(parser, instance=True)
    instances_flags.AddImageArgs(parser)
    instances_flags.AddMinCpuPlatformArgs(parser, base.ReleaseTrack.ALPHA)
    labels_util.AddCreateLabelsFlags(parser)

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

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

    CreateWithContainer.SOURCE_INSTANCE_TEMPLATE = (
        instances_flags.MakeSourceInstanceTemplateArg())
    CreateWithContainer.SOURCE_INSTANCE_TEMPLATE.AddArgument(parser)
    parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
コード例 #27
0
def _AddSubmitTrainingArgs(parser):
    """Add arguments for `jobs submit training` command."""
    flags.JOB_NAME.AddToParser(parser)
    flags.PACKAGE_PATH.AddToParser(parser)
    flags.PACKAGES.AddToParser(parser)
    flags.MODULE_NAME.AddToParser(parser)
    compute_flags.AddRegionFlag(parser, 'machine learning training job',
                                'submit')
    flags.CONFIG.AddToParser(parser)
    flags.STAGING_BUCKET.AddToParser(parser)
    flags.GetJobDirFlag(upload_help=True).AddToParser(parser)
    flags.GetUserArgs(local=False).AddToParser(parser)
    jobs_util.ScaleTierFlagMap().choice_arg.AddToParser(parser)
    flags.RUNTIME_VERSION.AddToParser(parser)

    sync_group = parser.add_mutually_exclusive_group()
    # TODO(b/36195821): Use the flag deprecation machinery when it supports the
    # store_true action
    sync_group.add_argument(
        '--async',
        action='store_true',
        help=(
            '(DEPRECATED) Display information about the operation in progress '
            'without waiting for the operation to complete. '
            'Enabled by default and can be omitted; use `--stream-logs` to run '
            'synchronously.'))
    sync_group.add_argument(
        '--stream-logs',
        action='store_true',
        help=
        ('Block until job completion and stream the logs while the job runs.'
         '\n\n'
         'Note that even if command execution is halted, the job will still '
         'run until cancelled with\n\n'
         '    $ gcloud ml-engine jobs cancel JOB_ID'))
    labels_util.AddCreateLabelsFlags(parser)
コード例 #28
0
ファイル: create.py プロジェクト: hemanthk92/CaseRoutingDemo
 def Args(parser):
   """Args is called by calliope to gather arguments for this command."""
   AddBaseArgs(parser)
   flags.AddInstanceResizeLimit(parser)
   labels_util.AddCreateLabelsFlags(parser)
コード例 #29
0
ファイル: create.py プロジェクト: campionfellin/hacktech
def _CommonArgs(parser):
    """Register flags common to all tracks."""
    instances_flags.AddTagsArgs(parser)
    base.ASYNC_FLAG.AddToParser(parser)
    labels_util.AddCreateLabelsFlags(parser)
    parser.add_argument(
        '--metadata',
        type=arg_parsers.ArgDict(min_length=1),
        action='append',
        default=None,
        help=('Metadata to be made available to the guest operating system '
              'running on the instances'),
        metavar='KEY=VALUE')
    parser.add_argument('name', help='The name of this cluster.')
    parser.add_argument(
        '--num-workers',
        type=int,
        help='The number of worker nodes in the cluster. Defaults to '
        'server-specified.')
    parser.add_argument(
        '--num-preemptible-workers',
        type=int,
        help='The number of preemptible worker nodes in the cluster.')
    parser.add_argument(
        '--main-machine-type',
        help='The type of machine to use for the main. Defaults to '
        'server-specified.')
    parser.add_argument(
        '--worker-machine-type',
        help='The type of machine to use for workers. Defaults to '
        'server-specified.')
    parser.add_argument('--image', hidden=True)
    parser.add_argument(
        '--image-version',
        metavar='VERSION',
        help='The image version to use for the cluster. Defaults to the '
        'latest version.')
    parser.add_argument(
        '--bucket',
        help='The Google Cloud Storage bucket to use with the Google Cloud '
        'Storage connector. A bucket is auto created when this parameter is '
        'not specified.')

    netparser = parser.add_mutually_exclusive_group()
    netparser.add_argument('--network',
                           help="""\
      The Compute Engine network that the VM instances of the cluster will be
      part of. This is mutually exclusive with --subnet. If neither is
      specified, this defaults to the "default" network.
      """)
    netparser.add_argument('--subnet',
                           help="""\
      Specifies the subnet that the cluster will be part of. This is mutally
      exclusive with --network.
      """)
    parser.add_argument(
        '--zone',
        '-z',
        help='The compute zone (e.g. us-central1-a) for the cluster.',
        action=actions.StoreProperty(properties.VALUES.compute.zone))
    parser.add_argument(
        '--num-worker-local-ssds',
        type=int,
        help='The number of local SSDs to attach to each worker in a cluster.')
    parser.add_argument(
        '--num-main-local-ssds',
        type=int,
        help='The number of local SSDs to attach to the main in a cluster.')
    parser.add_argument(
        '--initialization-actions',
        type=arg_parsers.ArgList(min_length=1),
        metavar='CLOUD_STORAGE_URI',
        help=('A list of Google Cloud Storage URIs of '
              'executables to run on each node in the cluster.'))
    parser.add_argument(
        '--initialization-action-timeout',
        type=arg_parsers.Duration(),
        metavar='TIMEOUT',
        default='10m',
        help='The maximum duration of each initialization action.')
    parser.add_argument('--properties',
                        type=arg_parsers.ArgDict(),
                        metavar='PREFIX:PROPERTY=VALUE',
                        default={},
                        help="""\
Specifies configuration properties for installed packages, such as Hadoop
and Spark.

Properties are mapped to configuration files by specifying a prefix, such as
"core:io.serializations". The following are supported prefixes and their
mappings:

[format="csv",options="header"]
|========
Prefix,Target Configuration File
core,core-site.xml
hdfs,hdfs-site.xml
mapred,mapred-site.xml
yarn,yarn-site.xml
hive,hive-site.xml
pig,pig.properties
spark,spark-defaults.conf
|========

""")
    parser.add_argument(
        '--service-account',
        help='The Google Cloud IAM service account to be authenticated as.')
    parser.add_argument('--scopes',
                        type=arg_parsers.ArgList(min_length=1),
                        metavar='SCOPE',
                        help="""\
Specifies scopes for the node instances. The project's default service account
is used. Multiple SCOPEs can specified, separated by commas.
Examples:

  $ {{command}} example-cluster --scopes https://www.googleapis.com/auth/bigtable.admin

  $ {{command}} example-cluster --scopes sqlservice,bigquery

The following scopes necessary for the cluster to function properly are always
added, even if not explicitly specified:

[format="csv"]
|========
{minimum_scopes}
|========

If this flag is not specified the following default scopes are also included:

[format="csv"]
|========
{additional_scopes}
|========

If you want to enable all scopes use the 'cloud-platform' scope.

SCOPE can be either the full URI of the scope or an alias.
Available aliases are:

[format="csv",options="header"]
|========
Alias,URI
{aliases}
|========
""".format(minimum_scopes='\n'.join(constants.MINIMUM_SCOPE_URIS),
           additional_scopes='\n'.join(
               constants.ADDITIONAL_DEFAULT_SCOPE_URIS),
           aliases=compute_helpers.SCOPE_ALIASES_FOR_HELP))

    main_boot_disk = parser.add_mutually_exclusive_group()
    worker_boot_disk = parser.add_mutually_exclusive_group()

    # Deprecated, to be removed at a future date.
    main_boot_disk.add_argument('--main-boot-disk-size-gb',
                                type=int,
                                hidden=True)
    worker_boot_disk.add_argument('--worker-boot-disk-size-gb',
                                  type=int,
                                  hidden=True)

    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.
      """
    main_boot_disk.add_argument(
        '--main-boot-disk-size',
        type=arg_parsers.BinarySize(lower_bound='10GB'),
        help=boot_disk_size_detailed_help)
    worker_boot_disk.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="""\
      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.
      """)
コード例 #30
0
 def Args(cls, parser):
   super(CreateBeta, cls).Args(parser)
   labels_util.AddCreateLabelsFlags(parser)