Example #1
0
def AddMetadataArgs(parser):
    """Adds --metadata and --metadata-from-file flags."""
    metadata = parser.add_argument(
        '--metadata',
        action=arg_parsers.AssociativeList(),
        default={},
        help=('Metadata to be made available to the guest operating system '
              'running on the instances'),
        metavar='KEY=VALUE',
        nargs='+')
    metadata.detailed_help = """\
      Metadata to be made available to the guest operating system
      running on the instances. Each metadata entry is a key/value
      pair separated by an equals sign. Metadata keys must be unique
      and less than 128 bytes in length. Values must be less than or
      equal to 32,768 bytes in length. Multiple arguments can be
      passed to this flag, e.g., ``--metadata key-1=value-1
      key-2=value-2 key-3=value-3''.

      In images that have
      link:https://developers.google.com/compute/docs/building-image[Compute
      Engine tools installed] on them, the following metadata keys
      have special meanings:

      *startup-script*::: Specifies a script that will be executed
      by the instances once they start running. For convenience,
      ``--metadata-from-file'' can be used to pull the value from a
      file.

      *startup-script-url*::: Same as ``startup-script'' except that
      the script contents are pulled from a publicly-accessible
      location on the web.
      """

    metadata_from_file = parser.add_argument(
        '--metadata-from-file',
        action=arg_parsers.AssociativeList(),
        default={},
        help=('Same as ``--metadata'
              ' except that the value for the entry '
              'will be read from a local file.'),
        metavar='KEY=LOCAL_FILE_PATH',
        nargs='+')
    metadata_from_file.detailed_help = """\
Example #2
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. If omitted, a default size of 200 GB is used. 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(
      '--no-boot-disk-auto-delete',
      action='store_true',
      help=('If provided, boot disks will not be automatically deleted '
            'when their instances are deleted.'))

  disk = parser.add_argument(
      '--disk',
      action=arg_parsers.AssociativeList(spec={
          'name': str,
          'mode': str,
          'boot': str,
          'device-name': str,
          'auto-delete': str,
      }, append=True),
      help='Attaches persistent disks to the instances.',
      metavar='PROPERTY=VALUE',
      nargs='+')
  disk.detailed_help = """
Example #3
0
    def Args(parser):
        parser.add_argument(
            '--default-service',
            required=True,
            help=
            ('A backend service that will be used for requests that the path '
             'matcher cannot match.'))

        parser.add_argument(
            '--description',
            help='An optional, textual description for the path matcher.')

        parser.add_argument('--path-matcher-name',
                            required=True,
                            help='The name to assign to the path matcher.')

        parser.add_argument(
            '--path-rules',
            action=arg_parsers.AssociativeList(),
            default={},
            metavar='PATH=SERVICE',
            nargs='+',
            help='Rules for mapping request paths to services.')

        host_rule = parser.add_mutually_exclusive_group()

        host_rule.add_argument(
            '--new-hosts',
            metavar='NEW_HOST',
            nargs='+',
            help=(
                'If specified, a new host rule with the given hosts is created'
                'and the path matcher is tied to the new host rule.'))

        existing_host = host_rule.add_argument(
            '--existing-host',
            help='An existing host rule to tie the new path matcher to.')
        existing_host.detailed_help = """\
        An existing host rule to tie the new path matcher to. Although
        host rules can contain more than one host, only a single host
        is needed to uniquely identify the host rule.
        """

        parser.add_argument(
            '--delete-orphaned-path-matcher',
            action='store_true',
            default=False,
            help=
            ('If provided and a path matcher is orphaned as a result of this '
             'command, the command removes the orphaned path matcher instead '
             'of failing.'))

        parser.add_argument('name', help='The name of the URL map.')
Example #4
0
def AddLocalSsdArgs(parser):
    """Adds local SSD argument for instances and instance-templates."""

    local_ssd = parser.add_argument(
        '--local-ssd',
        action=arg_parsers.AssociativeList(spec={
            'device-name': str,
            'interface': (lambda x: x.upper()),
        },
                                           append=True),
        help='(BETA) Specifies instances with attached local SSDs.',
        metavar='PROPERTY=VALUE',
        nargs='*')
    local_ssd.detailed_help = """
Example #5
0
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.
    """
        parser.add_argument(
            '--activation-policy',
            required=False,
            choices=['ALWAYS', 'NEVER', 'ON_DEMAND'],
            help=
            'The activation policy for this instance. This specifies when the '
            'instance should be activated and is applicable only when the '
            'instance state is RUNNABLE.')
        assign_ip_group = parser.add_mutually_exclusive_group()
        assign_ip_group.add_argument(
            '--assign-ip',
            required=False,
            action='store_true',
            help='Specified if the instance must be assigned an IP address.')
        assign_ip_group.add_argument(
            '--no-assign-ip',
            required=False,
            action='store_true',
            help='Specified if the assigned IP address must be revoked.')
        gae_apps_group = parser.add_mutually_exclusive_group()
        gae_apps_group.add_argument(
            '--authorized-gae-apps',
            required=False,
            nargs='+',
            type=str,
            help='A list of App Engine app IDs that can access this instance.')
        gae_apps_group.add_argument(
            '--clear-gae-apps',
            required=False,
            action='store_true',
            help=
            ('Specified to clear the list of App Engine apps that can access '
             'this instance.'))
        networks_group = parser.add_mutually_exclusive_group()
        networks_group.add_argument(
            '--authorized-networks',
            required=False,
            nargs='+',
            type=str,
            help=
            'The list of external networks that are allowed to connect to the '
            'instance. Specified in CIDR notation, also known as \'slash\' '
            'notation (e.g. 192.168.100.0/24).')
        networks_group.add_argument(
            '--clear-authorized-networks',
            required=False,
            action='store_true',
            help=
            'Clear the list of external networks that are allowed to connect '
            'to the instance.')
        backups_group = parser.add_mutually_exclusive_group()
        backups_group.add_argument(
            '--backup-start-time',
            required=False,
            help=
            'The start time of daily backups, specified in the 24 hour format '
            '- HH:MM, in the UTC timezone.')
        backups_group.add_argument(
            '--no-backup',
            required=False,
            action='store_true',
            help='Specified if daily backup should be disabled.')
        database_flags_group = parser.add_mutually_exclusive_group()
        database_flags_group.add_argument(
            '--database-flags',
            required=False,
            nargs='+',
            action=arg_parsers.AssociativeList(),
            help=
            'A space-separated list of database flags to set on the instance. '
            'Use an equals sign to separate flag name and value. Flags without '
            'values, like skip_grant_tables, can be written out without a value '
            'after, e.g., `skip_grant_tables=`. Use on/off for '
            'booleans. View the Instance Resource API for allowed flags. '
            '(e.g., `--database-flags max_allowed_packet=55555 skip_grant_tables= '
            'log_output=1`)')
        database_flags_group.add_argument(
            '--clear-database-flags',
            required=False,
            action='store_true',
            help='Clear the database flags set on the instance. '
            'WARNING: Instance will be restarted.')
        bin_log_group = parser.add_mutually_exclusive_group()
        bin_log_group.add_argument(
            '--enable-bin-log',
            required=False,
            action='store_true',
            help='Specified if binary log should be enabled. If backup '
            'configuration is disabled, binary log should be disabled as well.'
        )
        bin_log_group.add_argument(
            '--no-enable-bin-log',
            required=False,
            action='store_true',
            help='Specified if binary log should be disabled.')
        parser.add_argument(
            '--follow-gae-app',
            required=False,
            help='The App Engine app this instance should follow. It must be in '
            'the same region as the instance. '
            'WARNING: Instance may be restarted.')
        parser.add_argument(
            '--gce-zone',
            required=False,
            help='The preferred Compute Engine zone (e.g. us-central1-a, '
            'us-central1-b, etc.). '
            'WARNING: Instance may be restarted.')
        parser.add_argument('instance', help='Cloud SQL instance ID.')
        parser.add_argument('--pricing-plan',
                            '-p',
                            required=False,
                            choices=['PER_USE', 'PACKAGE'],
                            help='The pricing plan for this instance.')
        parser.add_argument('--replication',
                            required=False,
                            choices=['SYNCHRONOUS', 'ASYNCHRONOUS'],
                            help='The type of replication this instance uses.')
        require_ssl_group = parser.add_mutually_exclusive_group()
        require_ssl_group.add_argument(
            '--require-ssl',
            required=False,
            action='store_true',
            help=
            'Specified if the mysqld should default to \'REQUIRE X509\' for '
            'users connecting over IP.')
        require_ssl_group.add_argument(
            '--no-require-ssl',
            required=False,
            action='store_true',
            help=
            'Specified if the mysqld should not default to \'REQUIRE X509\' '
            'for users connecting over IP.')
        parser.add_argument(
            '--tier',
            '-t',
            required=False,
            help='The tier of service for this instance, for example D0, D1. '
            'WARNING: Instance will be restarted.')
        database_replication_group = parser.add_mutually_exclusive_group()
        database_replication_group.add_argument(
            '--enable-database-replication',
            required=False,
            action='store_true',
            help='Specified if database replication is enabled. Applicable only '
            'for read replica instance(s). WARNING: Instance will be restarted.'
        )
        database_replication_group.add_argument(
            '--no-enable-database-replication',
            required=False,
            action='store_true',
            help=
            'Specified if database replication is disabled. Applicable only '
            'for read replica instance(s). WARNING: Instance will be restarted.'
        )
        parser.add_argument('--async',
                            action='store_true',
                            help='Do not wait for the operation to complete.')
        parser.add_argument(
            '--diff',
            action='store_true',
            help='Show what changed as a result of the update.')
Example #6
0
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.
    """
        parser.add_argument(
            '--activation-policy',
            required=False,
            choices=['ALWAYS', 'NEVER', 'ON_DEMAND'],
            default=None,
            help=
            'The activation policy for this instance. This specifies when the '
            'instance should be activated and is applicable only when the '
            'instance state is RUNNABLE.')
        parser.add_argument(
            '--assign-ip',
            required=False,
            action='store_true',
            help='Specified if the instance must be assigned an IP address.')
        parser.add_argument(
            '--authorized-gae-apps',
            required=False,
            nargs='+',
            type=str,
            default=[],
            help='List of App Engine app IDs that can access this instance.')
        parser.add_argument(
            '--authorized-networks',
            required=False,
            nargs='+',
            type=str,
            default=[],
            help=
            'The list of external networks that are allowed to connect to the'
            ' instance. Specified in CIDR notation, also known as \'slash\' '
            'notation (e.g. 192.168.100.0/24).')
        parser.add_argument(
            '--backup-start-time',
            required=False,
            help=
            'The start time of daily backups, specified in the 24 hour format '
            '- HH:MM, in the UTC timezone.')
        parser.add_argument(
            '--no-backup',
            required=False,
            action='store_true',
            help='Specified if daily backup should be disabled.')
        parser.add_argument(
            '--database-version',
            required=False,
            choices=['MYSQL_5_5', 'MYSQL_5_6'],
            default='MYSQL_5_5',
            help='The database engine type and version. Can be MYSQL_5_5 or '
            'MYSQL_5_6.')
        parser.add_argument(
            '--enable-bin-log',
            required=False,
            action='store_true',
            help='Specified if binary log should be enabled. If backup '
            'configuration is disabled, binary log must be disabled as well.')
        parser.add_argument(
            '--follow-gae-app',
            required=False,
            help='The App Engine app this instance should follow. It must be in '
            'the same region as the instance.')
        parser.add_argument(
            '--gce-zone',
            required=False,
            help='The preferred Compute Engine zone (e.g. us-central1-a, '
            'us-central1-b, etc.).')
        parser.add_argument('instance', help='Cloud SQL instance ID.')
        parser.add_argument(
            '--master-instance-name',
            required=False,
            help=
            'Name of the instance which will act as master in the replication '
            'setup. The newly created instance will be a read replica of the '
            'specified master instance.')
        parser.add_argument('--pricing-plan',
                            '-p',
                            required=False,
                            choices=['PER_USE', 'PACKAGE'],
                            default='PER_USE',
                            help='The pricing plan for this instance.')
        parser.add_argument(
            '--region',
            required=False,
            choices=['us-east1', 'europe-west1'],
            default='us-east1',
            help='The geographical region. Can be us-east1 or europe-west1.')
        parser.add_argument('--replication',
                            required=False,
                            choices=['SYNCHRONOUS', 'ASYNCHRONOUS'],
                            default=None,
                            help='The type of replication this instance uses.')
        parser.add_argument(
            '--require-ssl',
            required=False,
            action='store_true',
            help='Specified if users connecting over IP must use SSL.')
        parser.add_argument(
            '--tier',
            '-t',
            required=False,
            default='D1',
            help='The tier of service for this instance, for example D0, D1.')
        parser.add_argument(
            '--database-flags',
            required=False,
            nargs='+',
            action=arg_parsers.AssociativeList(),
            help=
            'A space-separated list of database flags to set on the instance. '
            'Use an equals sign to separate flag name and value. Flags without '
            'values, like skip_grant_tables, can be written out without a value '
            'after, e.g., `skip_grant_tables=`. Use on/off for '
            'booleans. View the Instance Resource API for allowed flags. '
            '(e.g., `--database-flags max_allowed_packet=55555 skip_grant_tables= '
            'log_output=1`)')
        parser.add_argument('--async',
                            action='store_true',
                            help='Do not wait for the operation to complete.')