Beispiel #1
0
def AddBaseArgs(parser, pitr_options_group):
  """Add args common to all release tracks to parser."""
  base.ASYNC_FLAG.AddToParser(parser)
  parser.display_info.AddFormat(flags.GetInstanceListFormat())
  parser.add_argument(
      'source',
      completer=flags.InstanceCompleter,
      help='Cloud SQL instance ID of the source.')
  parser.add_argument('destination', help='Cloud SQL instance ID of the clone.')
  bin_log_group = pitr_options_group.add_group(
      mutex=False,
      required=False,
      help='Binary log coordinates for point-in-time recovery.')
  bin_log_group.add_argument(
      '--bin-log-file-name',
      required=True,
      help="""\
      The name of the binary log file. Enable point-in-time recovery on the
      source instance to create a binary log file. If specified with
      <--bin-log-position> to form a valid binary log coordinate, it defines an
      earlier point in time to clone a source instance from.
      For example, mysql-bin.000001.
      """)
  bin_log_group.add_argument(
      '--bin-log-position',
      type=int,
      required=True,
      help="""\
      Represents the state of an instance at any given point in time inside a
      binary log file. If specified along with <--bin-log-file-name> to form a
      valid binary log coordinate, it defines an earlier point in time to clone
      a source instance from.
      For example, 123 (a numeric value).
      """)
Beispiel #2
0
 def Args(cls, parser):
     """Declare flag and positional arguments for the command parser."""
     base.ASYNC_FLAG.AddToParser(parser)
     parser.display_info.AddFormat(flags.GetInstanceListFormat())
     parser.add_argument('source',
                         completer=flags.InstanceCompleter,
                         help='Cloud SQL instance ID of the source.')
     parser.add_argument('destination',
                         help='Cloud SQL instance ID of the clone.')
     parser.add_argument('--bin-log-file-name',
                         required=False,
                         help="""\
     Represents the name of the binary log file created by the source
     instance if it has binary logs enabled.
     If specified, is the point up to which the source instance is cloned.
     It must be specified along with --bin-log-position to form a valid
     binary log coordinates.
     e.g., mysql-bin.000001
     """)
     parser.add_argument('--bin-log-position',
                         type=int,
                         required=False,
                         help="""\
     Represents the position (offset) inside the binary log file created by
     the source instance if it has binary logs enabled.
     If specified, is the point up to which the source instance is cloned.
     It must be specified along with --bin-log-file to form a valid binary
     log coordinates.
     e.g., 123 (a numeric value)
     """)
     parser.display_info.AddCacheUpdater(flags.InstanceCompleter)
def AddBaseArgs(parser):
  """Add args common to all release tracks to parser."""
  base.ASYNC_FLAG.AddToParser(parser)
  parser.display_info.AddFormat(flags.GetInstanceListFormat())
  parser.add_argument(
      'source',
      completer=flags.InstanceCompleter,
      help='Cloud SQL instance ID of the source.')
  parser.add_argument('destination', help='Cloud SQL instance ID of the clone.')

  pitr_options_group = parser.add_group(mutex=True, required=False)
  bin_log_group = pitr_options_group.add_group(
      mutex=False,
      required=False,
      help='Binary log coordinates for point-in-time recovery.')
  bin_log_group.add_argument(
      '--bin-log-file-name',
      required=True,
      help="""\
      The name of the binary log file. Enable point-in-time recovery on the
      source instance to create a binary log file. If specified with
      <--bin-log-position> to form a valid binary log coordinate, it defines an
      earlier point in time to clone a source instance from.
      For example, mysql-bin.000001.
      """)
  bin_log_group.add_argument(
      '--bin-log-position',
      type=int,
      required=True,
      help="""\
      Represents the state of an instance at any given point in time inside a
      binary log file. If specified along with <--bin-log-file-name> to form a
      valid binary log coordinate, it defines an earlier point in time to clone
      a source instance from.
      For example, 123 (a numeric value).
      """)
  pitr_options_group.add_argument(
      '--point-in-time',
      type=arg_parsers.Datetime.Parse,
      required=False,
      help="""\
      Represents the state of an instance at any given point in time inside
      a transaction log file. For MySQL, the binary log file is used for
      transaction logs. For PostgreSQL, the write-ahead log file is used for
      transaction logs. To create a transaction log, enable point-in-time
      recovery on the source instance. Instance should have transaction logs
      accumulated upto the point in time they want to restore upto.
      Uses RFC 3339 format in UTC timezone. If specified, defines a past
      state of the instance to clone.
      For example, '2012-11-15T16:19:00.094Z'.
      """)
Beispiel #4
0
def AddBaseArgs(parser):
    """Declare flag and positional arguments for this command parser."""
    # TODO(b/35705305): move common flags to command_lib.sql.flags
    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(flags.GetInstanceListFormat())
    flags.AddActivationPolicy(parser)
    flags.AddAssignIp(parser)
    flags.AddAuthorizedGAEApps(parser)
    flags.AddAuthorizedNetworks(parser)
    flags.AddAvailabilityType(parser)
    parser.add_argument('--backup',
                        required=False,
                        action='store_true',
                        default=True,
                        help='Enables daily backup.')
    flags.AddBackupStartTime(parser)
    flags.AddCPU(parser)
    flags.AddDatabaseFlags(parser)
    flags.AddEnableBinLog(parser, show_negated_in_help=False)
    parser.add_argument(
        '--failover-replica-name',
        required=False,
        help='Also create a failover replica with the specified name.')
    parser.add_argument(
        '--follow-gae-app',
        required=False,
        help=('First Generation instances only. The App Engine app this '
              'instance should follow. It must be in the same region as '
              'the instance.'))
    parser.add_argument('instance',
                        type=command_validate.InstanceNameRegexpValidator(),
                        help='Cloud SQL instance ID.')
    flags.AddMaintenanceReleaseChannel(parser)
    flags.AddMaintenanceWindowDay(parser)
    flags.AddMaintenanceWindowHour(parser)
    parser.add_argument(
        '--main-instance-name',
        required=False,
        help=('Name of the instance which will act as main in the '
              'replication setup. The newly created instance will be a read '
              'replica of the specified main instance.'))
    flags.AddMemory(parser)
    parser.add_argument(
        '--pricing-plan',
        '-p',
        required=False,
        choices=['PER_USE', 'PACKAGE'],
        default='PER_USE',
        help=('First Generation instances only. The pricing plan for this '
              'instance.'))
    # TODO(b/31989340): add remote completion
    # TODO(b/73362371): Make specifying a location required.
    location_group = parser.add_mutually_exclusive_group()
    location_group.add_argument(
        '--region',
        required=False,
        default='us-central',
        help=('Regional location (e.g. asia-east1, us-east1). See the full '
              'list of regions at '
              'https://cloud.google.com/sql/docs/instance-locations.'))
    flags.AddZone(
        location_group,
        help_text=('Preferred Compute Engine zone (e.g. us-central1-a, '
                   'us-central1-b, etc.).'))
    parser.add_argument('--replica-type',
                        choices=['READ', 'FAILOVER'],
                        help='The type of replica to create.')
    flags.AddReplication(parser)
    parser.add_argument(
        '--require-ssl',
        required=False,
        action='store_true',
        default=None,
        help='Specified if users connecting over IP must use SSL.')
    flags.AddRootPassword(parser)
    flags.AddStorageAutoIncrease(parser)
    flags.AddStorageSize(parser)
    parser.add_argument(
        '--storage-type',
        required=False,
        choices=['SSD', 'HDD'],
        default=None,
        help='The storage type for the instance. The default is SSD.')
    flags.AddTier(parser)
Beispiel #5
0
 def Args(parser):
     parser.display_info.AddFormat(flags.GetInstanceListFormat())
     parser.display_info.AddUriFunc(_GetUriFromResource)
def AddBaseArgs(parser, is_alpha=False):
  """Declare flag and positional arguments for this command parser."""
  # TODO(b/35705305): move common flags to command_lib.sql.flags
  base.ASYNC_FLAG.AddToParser(parser)
  parser.display_info.AddFormat(flags.GetInstanceListFormat())
  flags.AddActivationPolicy(parser)
  flags.AddActiveDirectoryDomain(parser)
  flags.AddAssignIp(parser)
  flags.AddAuthorizedNetworks(parser)
  flags.AddAvailabilityType(parser)
  parser.add_argument(
      '--backup',
      required=False,
      action='store_true',
      default=True,
      help='Enables daily backup.')
  flags.AddBackupStartTime(parser)
  flags.AddBackupLocation(parser, allow_empty=False)
  flags.AddCPU(parser)
  flags.AddInstanceCollation(parser)
  flags.AddDatabaseFlags(parser)
  flags.AddEnableBinLog(parser, show_negated_in_help=False)
  flags.AddRetainedBackupsCount(parser)
  flags.AddRetainedTransactionLogDays(parser)

  parser.add_argument(
      '--failover-replica-name',
      required=False,
      help='Also create a failover replica with the specified name.')
  parser.add_argument(
      'instance',
      type=command_validate.InstanceNameRegexpValidator(),
      help='Cloud SQL instance ID.')
  flags.AddMaintenanceReleaseChannel(parser)
  flags.AddMaintenanceWindowDay(parser)
  flags.AddMaintenanceWindowHour(parser)
  flags.AddDenyMaintenancePeriodStartDate(parser)
  flags.AddDenyMaintenancePeriodEndDate(parser)
  flags.AddDenyMaintenancePeriodTime(parser)
  flags.AddInsightsConfigQueryInsightsEnabled(parser, show_negated_in_help=True)
  flags.AddInsightsConfigQueryStringLength(parser)
  flags.AddInsightsConfigRecordApplicationTags(
      parser, show_negated_in_help=True)
  flags.AddInsightsConfigRecordClientAddress(parser, show_negated_in_help=True)
  flags.AddInsightsConfigQueryPlansPerMinute(parser)
  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.'))
  flags.AddMemory(parser)
  flags.AddPasswordPolicyMinLength(parser)
  flags.AddPasswordPolicyComplexity(parser)
  flags.AddPasswordPolicyReuseInterval(parser)
  flags.AddPasswordPolicyDisallowUsernameSubstring(parser)
  flags.AddPasswordPolicyPasswordChangeInterval(parser)
  flags.AddPasswordPolicyEnablePasswordPolicy(parser)
  parser.add_argument(
      '--replica-type',
      choices=['READ', 'FAILOVER'],
      help='The type of replica to create.')
  flags.AddReplication(parser)
  parser.add_argument(
      '--require-ssl',
      required=False,
      action='store_true',
      default=None,
      help='Specified if users connecting over IP must use SSL.')
  flags.AddRootPassword(parser)
  flags.AddStorageAutoIncrease(parser)
  flags.AddStorageSize(parser)
  parser.add_argument(
      '--storage-type',
      required=False,
      choices=['SSD', 'HDD'],
      default=None,
      help='The storage type for the instance. The default is SSD.')
  flags.AddTier(parser, is_alpha=is_alpha)
  kms_flag_overrides = {
      'kms-key': '--disk-encryption-key',
      'kms-keyring': '--disk-encryption-key-keyring',
      'kms-location': '--disk-encryption-key-location',
      'kms-project': '--disk-encryption-key-project'
  }
  kms_resource_args.AddKmsKeyResourceArg(
      parser,
      'instance',
      flag_overrides=kms_flag_overrides)
  flags.AddEnablePointInTimeRecovery(parser)
  flags.AddNetwork(parser)
Beispiel #7
0
def AddBaseArgs(parser):
    """Declare flag and positional arguments for this command parser."""
    # TODO(b/35705305): move common flags to command_lib.sql.flags
    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(flags.GetInstanceListFormat())
    flags.AddActivationPolicy(parser)
    flags.AddAssignIp(parser)
    flags.AddAuthorizedNetworks(parser)
    flags.AddAvailabilityType(parser)
    parser.add_argument('--backup',
                        required=False,
                        action='store_true',
                        default=True,
                        help='Enables daily backup.')
    flags.AddBackupStartTime(parser)
    flags.AddBackupLocation(parser, allow_empty=False)
    flags.AddCPU(parser)
    flags.AddInstanceCollation(parser)
    flags.AddDatabaseFlags(parser)
    flags.AddEnableBinLog(parser, show_negated_in_help=False)
    parser.add_argument(
        '--failover-replica-name',
        required=False,
        help='Also create a failover replica with the specified name.')
    parser.add_argument('instance',
                        type=command_validate.InstanceNameRegexpValidator(),
                        help='Cloud SQL instance ID.')
    flags.AddMaintenanceReleaseChannel(parser)
    flags.AddMaintenanceWindowDay(parser)
    flags.AddMaintenanceWindowHour(parser)
    flags.AddDenyMaintenancePeriodStartDate(parser)
    flags.AddDenyMaintenancePeriodEndDate(parser)
    flags.AddDenyMaintenancePeriodTime(parser)
    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.'))
    flags.AddMemory(parser)
    # TODO(b/31989340): add remote completion
    # TODO(b/73362371): Make specifying a location required.
    location_group = parser.add_mutually_exclusive_group()
    location_group.add_argument(
        '--region',
        required=False,
        default='us-central',
        help=('Regional location (e.g. asia-east1, us-east1). See the full '
              'list of regions at '
              'https://cloud.google.com/sql/docs/instance-locations.'))
    flags.AddZone(
        location_group,
        help_text=('Preferred Compute Engine zone (e.g. us-central1-a, '
                   'us-central1-b, etc.).'))
    parser.add_argument('--replica-type',
                        choices=['READ', 'FAILOVER'],
                        help='The type of replica to create.')
    flags.AddReplication(parser)
    parser.add_argument(
        '--require-ssl',
        required=False,
        action='store_true',
        default=None,
        help='Specified if users connecting over IP must use SSL.')
    flags.AddRootPassword(parser)
    flags.AddStorageAutoIncrease(parser)
    flags.AddStorageSize(parser)
    parser.add_argument(
        '--storage-type',
        required=False,
        choices=['SSD', 'HDD'],
        default=None,
        help='The storage type for the instance. The default is SSD.')
    flags.AddTier(parser)
    kms_flag_overrides = {
        'kms-key': '--disk-encryption-key',
        'kms-keyring': '--disk-encryption-key-keyring',
        'kms-location': '--disk-encryption-key-location',
        'kms-project': '--disk-encryption-key-project'
    }
    kms_resource_args.AddKmsKeyResourceArg(parser,
                                           'instance',
                                           flag_overrides=kms_flag_overrides)
    flags.AddEnablePointInTimeRecovery(parser)
Beispiel #8
0
def AddBaseArgs(parser):
  """Declare flag and positional arguments for this command parser."""
  # TODO(b/35705305): move common flags to command_lib.sql.flags
  base.ASYNC_FLAG.AddToParser(parser)
  parser.display_info.AddFormat(flags.GetInstanceListFormat())
  flags.AddActivationPolicy(parser)
  flags.AddAssignIp(parser, show_negated_in_help=False)
  flags.AddAuthorizedGAEApps(parser)
  flags.AddAuthorizedNetworks(parser)
  flags.AddAvailabilityType(parser)
  parser.add_argument(
      '--backup',
      required=False,
      action='store_true',
      default=True,
      help='Enables daily backup.')
  flags.AddBackupStartTime(parser)
  flags.AddCPU(parser)
  flags.AddDatabaseFlags(parser)
  parser.add_argument(
      '--database-version',
      required=False,
      choices=['MYSQL_5_5', 'MYSQL_5_6', 'MYSQL_5_7', 'POSTGRES_9_6'],
      help=('The database engine type and version. If left unspecified, the '
            'API defaults will be used.'))
  flags.AddEnableBinLog(parser, show_negated_in_help=False)
  parser.add_argument(
      '--failover-replica-name',
      required=False,
      help='Also create a failover replica with the specified name.')
  parser.add_argument(
      '--follow-gae-app',
      required=False,
      help=('First Generation instances only. The App Engine app this '
            'instance should follow. It must be in the same region as '
            'the instance.'))
  # TODO(b/73362466): Add `--zone` and deprecate `--gce-zone`.
  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',
      type=command_validate.InstanceNameRegexpValidator(),
      help='Cloud SQL instance ID.')
  flags.AddMaintenanceReleaseChannel(parser)
  flags.AddMaintenanceWindowDay(parser)
  flags.AddMaintenanceWindowHour(parser)
  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.'))
  flags.AddMemory(parser)
  parser.add_argument(
      '--pricing-plan',
      '-p',
      required=False,
      choices=['PER_USE', 'PACKAGE'],
      default='PER_USE',
      help=('First Generation instances only. The pricing plan for this '
            'instance.'))
  # TODO(b/31989340): add remote completion
  # TODO(b/73362466): Make zone and region mutually exclusive.
  parser.add_argument(
      '--region',
      required=False,
      default='us-central',
      help=('The regional location (e.g. asia-east1, us-east1). See the full '
            'list of regions at '
            'https://cloud.google.com/sql/docs/instance-locations.'))
  parser.add_argument(
      '--replica-type',
      choices=['READ', 'FAILOVER'],
      help='The type of replica to create.')
  flags.AddReplication(parser)
  parser.add_argument(
      '--require-ssl',
      required=False,
      action='store_true',
      default=None,
      help='Specified if users connecting over IP must use SSL.')
  flags.AddStorageAutoIncrease(parser)
  flags.AddStorageSize(parser)
  parser.add_argument(
      '--storage-type',
      required=False,
      choices=['SSD', 'HDD'],
      default=None,
      help='The storage type for the instance. The default is SSD.')
  parser.add_argument(
      '--tier',
      '-t',
      required=False,
      help=('The tier for this instance. For Second Generation instances, '
            'TIER is the instance\'s machine type (e.g., db-n1-standard-1). '
            'For PostgreSQL instances, only shared-core machine types '
            '(e.g., db-f1-micro) apply. The default tier is db-n1-standard-1. '
            'A complete list of tiers is available here: '
            'https://cloud.google.com/sql/pricing'))