- Make validation a bit nicer:
- Add timeout to the DB validation - Make DB validation exception handling a bit nicer - Move the DB validation error message - Fix bug around RADOS config default for Is Secure - Allow hiding of the validation box
This commit is contained in:
parent
47fb10b79f
commit
bfd273d16f
6 changed files with 56 additions and 20 deletions
|
@ -2,6 +2,7 @@ import redis
|
|||
import os
|
||||
import json
|
||||
import ldap
|
||||
import peewee
|
||||
|
||||
from data.users import LDAPConnection
|
||||
from flask import Flask
|
||||
|
@ -35,12 +36,21 @@ def validate_service_for_config(service, config):
|
|||
|
||||
def _validate_database(config):
|
||||
""" Validates connecting to the database. """
|
||||
validate_database_url(config['DB_URI'])
|
||||
try:
|
||||
validate_database_url(config['DB_URI'])
|
||||
except peewee.OperationalError as ex:
|
||||
if ex.args and len(ex.args) > 1:
|
||||
raise Exception(ex.args[1])
|
||||
else:
|
||||
raise ex
|
||||
|
||||
|
||||
def _validate_redis(config):
|
||||
""" Validates connecting to redis. """
|
||||
redis_config = config['BUILDLOGS_REDIS']
|
||||
redis_config = config.get('BUILDLOGS_REDIS', {})
|
||||
if not 'host' in redis_config:
|
||||
raise Exception('Missing redis hostname')
|
||||
|
||||
client = redis.StrictRedis(socket_connect_timeout=5, **redis_config)
|
||||
client.ping()
|
||||
|
||||
|
|
Reference in a new issue