def _AddArgs(parser, multizonal):
    """Add args."""
    parser.add_argument('name', help='Managed instance group name.')
    parser.add_argument(
        '--target-pools',
        required=True,
        type=arg_parsers.ArgList(min_length=0),
        action=arg_parsers.FloatingListValuesCatcher(),
        metavar='TARGET_POOL',
        help=('Compute Engine Target Pools to add the instances to. '
              'Target Pools must be specified by name or by URL. Example: '
              '--target-pool target-pool-1,target-pool-2.'))
    if multizonal:
        scope_parser = parser.add_mutually_exclusive_group()
        utils.AddRegionFlag(
            scope_parser,
            resource_type='instance group manager',
            operation_type='set target pools',
            explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
        utils.AddZoneFlag(
            scope_parser,
            resource_type='instance group manager',
            operation_type='set target pools',
            explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
    else:
        utils.AddZoneFlag(parser,
                          resource_type='instance group manager',
                          operation_type='set target pools')
示例#2
0
def _AddArgs(parser, multizonal):
  """Adds args."""
  parser.add_argument('name', help='Managed instance group name.')
  parser.add_argument(
      '--instances',
      type=arg_parsers.ArgList(min_length=1),
      action=arg_parsers.FloatingListValuesCatcher(),
      metavar='INSTANCE',
      required=True,
      help='Names of instances to delete.')
  if multizonal:
    scope_parser = parser.add_mutually_exclusive_group()
    utils.AddRegionFlag(
        scope_parser,
        resource_type='instance group manager',
        operation_type='delete instances',
        explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
    utils.AddZoneFlag(
        scope_parser,
        resource_type='instance group manager',
        operation_type='delete instances',
        explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
  else:
    utils.AddZoneFlag(
        parser,
        resource_type='instance group manager',
        operation_type='delete instances')
示例#3
0
    def AddArgs(parser, multizonal):
        parser.add_argument('group', help='The name of the instance group.')

        parser.add_argument('--named-ports',
                            required=True,
                            type=arg_parsers.ArgList(),
                            action=arg_parsers.FloatingListValuesCatcher(),
                            metavar='NAME:PORT',
                            help="""\
            The comma-separated list of key:value pairs representing
            the service name and the port that it is running on.

            To clear the list of named ports pass empty list as flag value.
            For example:

              $ {command} example-instance-group --named-ports ""
            """)

        if multizonal:
            scope_parser = parser.add_mutually_exclusive_group()
            utils.AddRegionFlag(
                scope_parser,
                resource_type='instance group',
                operation_type='set named ports for',
                explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
            utils.AddZoneFlag(
                scope_parser,
                resource_type='instance group',
                operation_type='set named ports for',
                explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
        else:
            utils.AddZoneFlag(parser,
                              resource_type='instance group',
                              operation_type='set named ports for')
示例#4
0
    def AddArgs(parser, multizonal):
        parser.add_argument('name', help='The name of the instance group.')

        parser.add_argument('--limit',
                            type=arg_parsers.BoundedInt(1, sys.maxint),
                            help='The maximum number of results.')

        sort_by = parser.add_argument('--sort-by', help='A field to sort by.')
        sort_by.detailed_help = """\
        A field to sort by. To perform a descending-order sort, prefix
        the value of this flag with a tilde (``~'').
        """

        if multizonal:
            scope_parser = parser.add_mutually_exclusive_group()
            utils.AddRegionFlag(
                scope_parser,
                resource_type='instance or instance group',
                operation_type='get named ports for',
                explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
            utils.AddZoneFlag(
                scope_parser,
                resource_type='instance or instance group',
                operation_type='get named ports for',
                explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
        else:
            utils.AddZoneFlag(parser,
                              resource_type='instance or instance group',
                              operation_type='get named ports for')
示例#5
0
def _AddArgs(parser, multizonal):
    """Adds args."""
    managed_instance_groups_utils.AddAutoscalerArgs(parser)
    parser.add_argument(
        'name',
        metavar='NAME',
        completion_resource='compute.instanceGroupManagers',
        help='Managed instance group which autoscaling parameters will be set.'
    )
    if multizonal:
        scope_parser = parser.add_mutually_exclusive_group()
        utils.AddRegionFlag(
            scope_parser,
            resource_type='resources',
            operation_type='update',
            explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
        utils.AddZoneFlag(
            scope_parser,
            resource_type='resources',
            operation_type='update',
            explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
    else:
        utils.AddZoneFlag(parser,
                          resource_type='resources',
                          operation_type='update')
示例#6
0
def _AddArgs(parser, multizonal):
  """Adds args."""
  parser.add_argument('name',
                      help='Name of the managed instance group.')
  parser.add_argument('--timeout',
                      type=int,
                      help='Timeout in seconds for waiting '
                      'for group becoming stable.')
  if multizonal:
    scope_parser = parser.add_mutually_exclusive_group()
    utils.AddRegionFlag(
        scope_parser,
        resource_type='managed instance group',
        operation_type='wait until stable',
        explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
    utils.AddZoneFlag(
        scope_parser,
        resource_type='managed instance group',
        operation_type='wait until stable',
        explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
  else:
    utils.AddZoneFlag(
        parser,
        resource_type='managed instance group',
        operation_type='wait until stable')
示例#7
0
    def Args(parser):
        restart_on_failure = parser.add_argument(
            '--restart-on-failure',
            action='store_true',
            default=None,  # Tri-valued: None => don't change the setting.
            help='Restart instances if they are terminated by Compute Engine.')
        restart_on_failure.detailed_help = """\
        The instances will be restarted if they are terminated by Compute '
        Engine.  This does not affect terminations performed by the user.'
        """

        maintenance_policy = parser.add_argument(
            '--maintenance-policy',
            choices=MIGRATION_OPTIONS,
            type=lambda x: x.upper(),
            help=('Specifies the behavior of the instances when their host '
                  'machines undergo maintenance.'))
        maintenance_policy.detailed_help = """\
        Specifies the behavior of the instances when their host machines undergo
        maintenance. TERMINATE indicates that the instances should be
        terminated. MIGRATE indicates that the instances should be migrated to a
        new host. Choosing MIGRATE will temporarily impact the performance of
        instances during a migration event.
        """

        parser.add_argument(
            'name',
            metavar='INSTANCE',
            completion_resource='compute.instances',
            help=
            'The name of the instance for which to change scheduling options.')

        utils.AddZoneFlag(parser,
                          resource_type='instance',
                          operation_type='set scheduling settings for')
示例#8
0
    def Args(parser):
        utils.AddZoneFlag(parser,
                          resource_type='instance',
                          operation_type='configure disk auto-delete for')

        parser.add_argument(
            'name',
            metavar='INSTANCE',
            completion_resource='compute.instances',
            help=('The name of the instance for which to configure disk '
                  'auto-deletion.'))

        parser.add_argument('--auto-delete',
                            action='store_true',
                            help='Enables auto-delete for the given disk.')

        disk_group = parser.add_mutually_exclusive_group(required=True)

        disk = disk_group.add_argument(
            '--disk',
            help=('Specify a disk to set auto-delete for by persistent disk '
                  'name.'))
        disk.detailed_help = """\
        Specifies a disk to set auto-delete for by its resource name. If
        you specify a disk to set auto-delete for by persistent disk name,
        then you must not specify its device name using the
        ``--device-name'' flag.
        """

        device_name = disk_group.add_argument(
            '--device-name',
            help=('Specify a disk to set auto-delete for by the name the '
                  'guest operating system sees.'))
        device_name.detailed_help = """\
    def Args(parser):
        parser.add_argument('name', help='The name of the instance group.')

        parser.add_argument('--limit',
                            type=arg_parsers.BoundedInt(1, sys.maxint),
                            help='The maximum number of results.')

        sort_by = parser.add_argument('--sort-by', help='A field to sort by.')
        sort_by.detailed_help = """\
        A field to sort by. To perform a descending-order sort, prefix
        the value of this flag with a tilde (``~'').
        """

        uri = parser.add_argument(
            '--uri',
            action='store_true',
            help='If provided, a list of URIs is printed instead of a table.')
        uri.detailed_help = """\
        If provided, the list command will only print URIs for the
        resources returned.  If this flag is not provided, the list
        command will print a human-readable table of useful resource
        data.
        """

        utils.AddZoneFlag(parser,
                          resource_type='instance group',
                          operation_type='list instances in')
示例#10
0
    def Args(parser):
        disk_group = parser.add_mutually_exclusive_group(required=True)

        disk_name = disk_group.add_argument(
            '--disk', help='Specify a disk to remove by persistent disk name.')
        disk_name.detailed_help = """\
        Specifies a disk to detach by its resource name. If you specify a
        disk to remove by persistent disk name, then you must not specify its
        device name using the ``--device-name'' flag.
        """

        device_name = disk_group.add_argument(
            '--device-name',
            help=('Specify a disk to remove by the name the guest operating '
                  'system sees.'))
        device_name.detailed_help = """\
        Specifies a disk to detach by its device name, which is the name
        that the guest operating system sees. The device name is set
        at the time that the disk is attached to the instance, and needs not be
        the same as the persistent disk name. If the disk's device name is
        specified, then its persistent disk name must not be specified
        using the ``--disk'' flag.
        """

        parser.add_argument(
            'name',
            metavar='NAME',
            completion_resource='compute.instances',
            help='The name of the instance to detach the disk from.')

        utils.AddZoneFlag(parser,
                          resource_type='instance',
                          operation_type='detach a disk from')
def _CommonArgs(parser):
    """Register parser args common to all tracks."""
    metadata_utils.AddMetadataArgs(parser)
    instance_utils.AddDiskArgs(parser)
    instance_utils.AddLocalSsdArgs(parser)
    instance_utils.AddImageArgs(parser)
    instance_utils.AddCanIpForwardArgs(parser)
    instance_utils.AddAddressArgs(parser, instances=True)
    instance_utils.AddMachineTypeArgs(parser)
    instance_utils.AddMaintenancePolicyArgs(parser)
    instance_utils.AddNoRestartOnFailureArgs(parser)
    instance_utils.AddPreemptibleVmArgs(parser)
    instance_utils.AddScopeArgs(parser)
    instance_utils.AddTagsArgs(parser)
    instance_utils.AddCustomMachineTypeArgs(parser)
    instance_utils.AddNetworkArgs(parser)

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

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

    utils.AddZoneFlag(parser,
                      resource_type='instances',
                      operation_type='create')
示例#12
0
  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')
示例#13
0
 def Args(parser):
     parser.add_argument('name', help='Managed instance group name.')
     parser.add_argument(
         '--template',
         required=True,
         help=('Specifies the instance template to use when creating new '
               'instances.'))
     parser.add_argument(
         '--base-instance-name',
         required=True,
         help=
         ('The base name to use for the Compute Engine instances that will '
          'be created with the managed instance group.'))
     parser.add_argument(
         '--size',
         required=True,
         help=('The initial number of instances you want in this group.'))
     parser.add_argument('--description',
                         help='An optional description for this group.')
     parser.add_argument(
         '--target-pool',
         type=arg_parsers.ArgList(),
         action=arg_parsers.FloatingListValuesCatcher(),
         metavar='TARGET_POOL',
         help=('Specifies any target pools you want the instances of this '
               'managed instance group to be part of.'))
     utils.AddZoneFlag(parser,
                       resource_type='instance group manager',
                       operation_type='create')
示例#14
0
def _CommonArgs(parser):
    """Add parser arguments common to all tracks."""

    parser.add_argument('name',
                        metavar='INSTANCE',
                        completion_resource='compute.instances',
                        help='The name of the instance to attach the disk to.')

    parser.add_argument(
        '--device-name',
        help=('An optional name that indicates the disk name the guest '
              'operating system will see. (Note: Device name does not '
              'correspond to mounted volume name)'))

    parser.add_argument('--disk',
                        help='The name of the disk to attach to the instance.',
                        required=True)

    mode = parser.add_argument('--mode',
                               choices=MODE_OPTIONS,
                               default='rw',
                               help='Specifies the mode of the disk.')
    mode.detailed_help = """\
      Specifies the mode of the disk. Supported options are ``ro'' for
      read-only and ``rw'' for read-write. If omitted, ``rw'' is used as
      a default. It is an error to attach a disk in read-write mode to
      more than one instance.
      """

    utils.AddZoneFlag(parser,
                      resource_type='instance',
                      operation_type='attach a disk to')
示例#15
0
    def Args(parser):
        parser.add_argument(
            '--description',
            help=('An optional, textual description for the snapshots being '
                  'created.'))

        snapshot_names = parser.add_argument(
            '--snapshot-names',
            type=arg_parsers.ArgList(min_length=1),
            action=arg_parsers.FloatingListValuesCatcher(),
            metavar='SNAPSHOT_NAME',
            help='Names to assign to the snapshots.')
        snapshot_names.detailed_help = """\
        Names to assign to the snapshots. Without this option, the
        name of each snapshot will be a random, 16-character
        hexadecimal number that starts with a letter. The values of
        this option run parallel to the disks specified. For example,

          $ {command} my-disk-1 my-disk-2 my-disk-3 --snapshot-names snapshot-1,snapshot-2,snapshot-3

        will result in ``my-disk-1'' being snapshotted as
        ``snapshot-1'', ``my-disk-2'' as ``snapshot-2'', and so on.
        """

        parser.add_argument('disk_names',
                            metavar='DISK_NAME',
                            nargs='+',
                            completion_resource='compute.disks',
                            help='The names of the disks to snapshot.')

        utils.AddZoneFlag(parser,
                          resource_type='disks',
                          operation_type='snapshot')
    def Args(parser):
        utils.AddZoneFlag(parser,
                          resource_type='instance',
                          operation_type='delete an access config from')

        access_config_name = parser.add_argument(
            '--access-config-name',
            default=constants.DEFAULT_ACCESS_CONFIG_NAME,
            help='Specifies the name of the access configuration to delete.')
        access_config_name.detailed_help = """\
        Specifies the name of the access configuration to delete.
        ``{0}'' is used as the default if this flag is not provided.
        """.format(constants.DEFAULT_ACCESS_CONFIG_NAME)

        parser.add_argument(
            'name',
            completion_resource='compute.instances',
            help=('The name of the instance from which to delete the access '
                  'configuration.'))

        network_interface = parser.add_argument(
            '--network-interface',
            default='nic0',
            help=('Specifies the name of the network interface from which to '
                  'delete the access configuration.'))
        network_interface.detailed_help = """\
示例#17
0
 def Args(parser):
     parser.add_argument(
         'name',
         metavar='NAME',
         completion_resource='compute.instanceGroupManagers',
         help='Managed instance group which will no longer be autoscaled.')
     utils.AddZoneFlag(parser,
                       resource_type='resources',
                       operation_type='delete')
示例#18
0
 def Args(parser):
     parser.add_argument('name', help='Name of the managed instance group.')
     parser.add_argument('--timeout',
                         type=int,
                         help='Timeout in seconds for waiting '
                         'for group becoming stable.')
     utils.AddZoneFlag(parser,
                       resource_type='managed instance group',
                       operation_type='wait until stable')
示例#19
0
    def Args(parser):
        utils.AddZoneFlag(parser,
                          resource_type='instance',
                          operation_type='start')

        parser.add_argument('name',
                            nargs='+',
                            completion_resource='compute.instances',
                            help='The names of the instances to start.')
示例#20
0
 def Args(parser):
     parser.add_argument('name',
                         metavar='DISK',
                         completion_resource='compute.disks',
                         help='The name of the disk to move.')
     parser.add_argument('--destination-zone',
                         help='The zone to move the disk to.',
                         completion_resource='compute.zones',
                         required=True)
     utils.AddZoneFlag(parser, resource_type='disk', operation_type='move')
示例#21
0
def _AddArgs(parser, multizonal):
    """Adds args."""
    parser.add_argument('name', help='Managed instance group name.')
    parser.add_argument(
        '--template',
        required=True,
        help=('Specifies the instance template to use when creating new '
              'instances.'))
    parser.add_argument(
        '--base-instance-name',
        help=(
            'The base name to use for the Compute Engine instances that will '
            'be created with the managed instance group. If not provided '
            'base instance name will be the prefix of instance group name.'))
    parser.add_argument(
        '--size',
        required=True,
        help=('The initial number of instances you want in this group.'))
    parser.add_argument('--description',
                        help='An optional description for this group.')
    parser.add_argument(
        '--target-pool',
        type=arg_parsers.ArgList(),
        action=arg_parsers.FloatingListValuesCatcher(),
        metavar='TARGET_POOL',
        help=('Specifies any target pools you want the instances of this '
              'managed instance group to be part of.'))
    if multizonal:
        scope_parser = parser.add_mutually_exclusive_group()
        utils.AddRegionFlag(
            scope_parser,
            resource_type='instance group manager',
            operation_type='create',
            explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
        utils.AddZoneFlag(
            scope_parser,
            resource_type='instance group manager',
            operation_type='create',
            explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
    else:
        utils.AddZoneFlag(parser,
                          resource_type='instance group manager',
                          operation_type='create')
 def Args(parser):
   parser.add_argument('name', help='Managed instance group name.')
   parser.add_argument(
       '--template',
       required=True,
       help=('Compute Engine instance template resource to be used.'))
   utils.AddZoneFlag(
       parser,
       resource_type='instance group manager',
       operation_type='set instance template')
示例#23
0
 def Args(parser):
     parser.add_argument('name', help='Managed instance group name.')
     parser.add_argument(
         '--size',
         required=True,
         type=int,
         help=('Target number of instances in managed instance group.'))
     utils.AddZoneFlag(parser,
                       resource_type='instance group manager',
                       operation_type='resize')
示例#24
0
def _AddArgs(parser, multizonal):
    """Adds args."""
    parser.add_argument('name', help='Managed instance group name.')
    managed_instance_groups_utils.AddAutohealingArgs(parser)
    if multizonal:
        scope_parser = parser.add_mutually_exclusive_group()
        utils.AddRegionFlag(
            scope_parser,
            resource_type='instance group manager',
            operation_type='set autohealing policy',
            explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
        utils.AddZoneFlag(
            scope_parser,
            resource_type='instance group manager',
            operation_type='set autohealing policy',
            explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
    else:
        utils.AddZoneFlag(parser,
                          resource_type='instance group manager',
                          operation_type='set autohealing policy')
示例#25
0
 def Args(parser):
     managed_instance_groups_utils.AddAutoscalerArgs(parser)
     parser.add_argument(
         'name',
         metavar='NAME',
         completion_resource='compute.instanceGroupManagers',
         help=
         'Managed instance group which autoscaling parameters will be set.')
     utils.AddZoneFlag(parser,
                       resource_type='resources',
                       operation_type='update')
示例#26
0
    def ListInstancesArgs(parser, multizonal=False):
        parser.add_argument('name', help='The name of the instance group.')

        parser.add_argument('--limit',
                            type=arg_parsers.BoundedInt(1, sys.maxint),
                            help='The maximum number of results.')

        sort_by = parser.add_argument('--sort-by', help='A field to sort by.')
        sort_by.detailed_help = """\
        A field to sort by. To perform a descending-order sort, prefix
        the value of this flag with a tilde (``~'').
        """

        uri = parser.add_argument(
            '--uri',
            action='store_true',
            help='If provided, a list of URIs is printed instead of a table.')
        uri.detailed_help = """\
        If provided, the list command will only print URIs for the
        resources returned.  If this flag is not provided, the list
        command will print a human-readable table of useful resource
        data.
        """

        if multizonal:
            scope_parser = parser.add_mutually_exclusive_group()
            utils.AddRegionFlag(
                scope_parser,
                resource_type='instance group',
                operation_type='list instances in',
                explanation=constants.REGION_PROPERTY_EXPLANATION_NO_DEFAULT)
            utils.AddZoneFlag(
                scope_parser,
                resource_type='instance group',
                operation_type='list instances in',
                explanation=constants.ZONE_PROPERTY_EXPLANATION_NO_DEFAULT)
        else:
            utils.AddZoneFlag(parser,
                              resource_type='instance group',
                              operation_type='list instances in')
示例#27
0
    def Args(parser):
        parser.add_argument('--description',
                            help=('Specifies a textual description for the '
                                  'unmanaged instance group.'))

        parser.add_argument(
            'name',
            metavar='NAME',
            help='The name of the unmanaged instance group to create.')

        utils.AddZoneFlag(parser,
                          resource_type='unmanaged instance group',
                          operation_type='create')
示例#28
0
 def Args(parser):
   parser.add_argument('name', help='Managed instance group name.')
   parser.add_argument(
       '--instances',
       type=arg_parsers.ArgList(min_length=1),
       action=arg_parsers.FloatingListValuesCatcher(),
       metavar='INSTANCE',
       required=True,
       help='Names of instances to delete.')
   utils.AddZoneFlag(
       parser,
       resource_type='instance group manager',
       operation_type='delete instances')
示例#29
0
    def Args(parser):

        parser.add_argument(
            'name',
            metavar='NAME',
            completion_resource='compute.instances',
            help='The name of the instance to change the machine type for.')

        instance_utils.AddMachineTypeArgs(parser)
        instance_utils.AddCustomMachineTypeArgs(parser)

        utils.AddZoneFlag(parser,
                          resource_type='instance',
                          operation_type='change the machine type for')
示例#30
0
    def Args(parser):
        g = parser.add_mutually_exclusive_group(required=True)
        g.add_argument('--group',
                       help=('The name of the legacy instance group '
                             '(deprecated resourceViews API) to remove. '
                             'Use --instance-group flag instead.'))
        g.add_argument('--instance-group',
                       help='The name or URI of the instance group to remove.')

        utils.AddZoneFlag(parser,
                          resource_type='instance group',
                          operation_type='remove from the backend service')

        parser.add_argument('name', help='The name of the backend service.')