def _PrintAndConfirmWarningMessage(args, database_version):
    """Print and confirm warning indicating the effect of applying the patch."""
    continue_msg = None
    if any([args.tier, args.enable_database_replication is not None]):
        continue_msg = (
            'WARNING: This patch modifies a value that requires '
            'your instance to be restarted. Submitting this patch '
            'will immediately restart your instance if it\'s running.')
    elif any([args.database_flags, args.clear_database_flags]):
        database_type_fragment = 'mysql'
        if api_util.InstancesV1Beta4.IsPostgresDatabaseVersion(
                database_version):
            database_type_fragment = 'postgres'
        elif api_util.InstancesV1Beta4.IsSqlServerDatabaseVersion(
                database_version):
            database_type_fragment = 'sqlserver'
        flag_docs_url = 'https://cloud.google.com/sql/docs/{}/flags'.format(
            database_type_fragment)
        continue_msg = (
            'WARNING: This patch modifies database flag values, which may require '
            'your instance to be restarted. Check the list of supported flags - '
            '{} - to see if your instance will be restarted when this patch '
            'is submitted.'.format(flag_docs_url))
    else:
        if any([args.follow_gae_app, args.gce_zone]):
            continue_msg = (
                'WARNING: This patch modifies the zone your instance '
                'is set to run in, which may require it to be moved. '
                'Submitting this patch will restart your instance '
                'if it is running in a different zone.')

    if continue_msg and not console_io.PromptContinue(continue_msg):
        raise exceptions.CancelledError('canceled by the user.')
Beispiel #2
0
def _PrintAndConfirmWarningMessage(args):
  """Print and confirm warning indicating the effect of applying the patch."""
  continue_msg = None
  if any([
      args.tier, args.database_flags, args.clear_database_flags,
      args.enable_database_replication is not None
  ]):
    continue_msg = (
        'WARNING: This patch modifies a value that requires '
        'your instance to be restarted. Submitting this patch '
        'will immediately restart your instance if it\'s running.')
  else:
    if any([args.follow_gae_app, args.gce_zone]):
      continue_msg = ('WARNING: This patch modifies the zone your instance '
                      'is set to run in, which may require it to be moved. '
                      'Submitting this patch will restart your instance '
                      'if it is running in a different zone.')

  if continue_msg and not console_io.PromptContinue(continue_msg):
    raise exceptions.CancelledError('canceled by the user.')