- 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
|
@ -71,7 +71,9 @@ db_random_func = CallableProxy()
|
|||
|
||||
|
||||
def validate_database_url(url):
|
||||
driver = _db_from_url(url, {})
|
||||
driver = _db_from_url(url, {
|
||||
'connect_timeout': 5
|
||||
})
|
||||
driver.connect()
|
||||
driver.close()
|
||||
|
||||
|
|
|
@ -4923,4 +4923,9 @@ i.slack-icon {
|
|||
border: 1px solid #eee;
|
||||
vertical-align: middle;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.modal-footer.alert {
|
||||
text-align: left;
|
||||
margin-bottom: -16px;
|
||||
}
|
|
@ -546,7 +546,7 @@
|
|||
<div class="modal-header">
|
||||
<h4 class="modal-title"
|
||||
ng-show="mapped.$hasChanges && validationStatus(validating) == 'validating'">
|
||||
Validating Configuration... Please Wait
|
||||
Validating Configuration...
|
||||
</h4>
|
||||
<h4 class="modal-title"
|
||||
ng-show="mapped.$hasChanges && validationStatus(validating) == 'failed'">
|
||||
|
@ -595,6 +595,13 @@
|
|||
|
||||
<div class="modal-footer" ng-show="mapped.$hasChanges">
|
||||
<span ng-show="validating.length == 0">Please Wait...</span>
|
||||
|
||||
<button class="btn btn-default"
|
||||
ng-show="validationStatus(validating) == 'validating'"
|
||||
ng-click="cancelValidation()">
|
||||
Stop Validating
|
||||
</button>
|
||||
|
||||
<button class="btn btn-primary"
|
||||
ng-show="validationStatus(validating) == 'success'"
|
||||
ng-click="saveConfiguration()"
|
||||
|
|
|
@ -110,6 +110,12 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
return hasError ? 'failed' : 'success';
|
||||
};
|
||||
|
||||
$scope.cancelValidation = function() {
|
||||
$('#validateAndSaveModal').modal('hide');
|
||||
$scope.validating = null;
|
||||
$scope.savingConfiguration = false;
|
||||
};
|
||||
|
||||
$scope.validateService = function(serviceInfo) {
|
||||
var params = {
|
||||
'service': serviceInfo.service.id
|
||||
|
@ -238,6 +244,7 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
var allowedFields = $scope.STORAGE_CONFIG_FIELDS[value];
|
||||
var configObject = $scope.config.DISTRIBUTED_STORAGE_CONFIG.local[1];
|
||||
|
||||
// Remove any fields not allowed.
|
||||
for (var fieldName in configObject) {
|
||||
if (!configObject.hasOwnProperty(fieldName)) {
|
||||
continue;
|
||||
|
@ -251,6 +258,13 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
delete configObject[fieldName];
|
||||
}
|
||||
}
|
||||
|
||||
// Set any boolean fields to false.
|
||||
for (var i = 0; i < allowedFields.length; ++i) {
|
||||
if (allowedFields[i].kind == 'bool') {
|
||||
configObject[allowedFields[i].name] = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('config', function(value) {
|
||||
|
|
|
@ -348,10 +348,6 @@
|
|||
Could not connect to or validate the database configuration found. Please reconfigure to continue.
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning" ng-show="databaseInvalid">
|
||||
Database Validation Issue: {{ databaseInvalid }}
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Please enter the connection details for your <strong>empty</strong> database. The schema will be created in the following step.</p>
|
||||
</p>
|
||||
|
@ -369,33 +365,32 @@
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="config-table" ng-show="fields.kind">
|
||||
<tr>
|
||||
<tr ng-show="fields.kind">
|
||||
<td>Database Server:</td>
|
||||
<td>
|
||||
<span class="config-string-field" binding="fields.server"
|
||||
placeholder="The database server hostname"></span>
|
||||
placeholder="localhost"></span>
|
||||
<div class="help-text">
|
||||
The server (and optionally, custom port) where the database lives
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr ng-show="fields.kind">
|
||||
<td>Database Name:</td>
|
||||
<td>
|
||||
<span class="config-string-field" binding="fields.database"
|
||||
placeholder="The name of the database on the server"></span>
|
||||
placeholder="registry-database"></span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<tr ng-show="fields.kind">
|
||||
<td>Username:</td>
|
||||
<td>
|
||||
<span class="config-string-field" binding="fields.username"
|
||||
placeholder="Username for accessing the database"></span>
|
||||
<div class="help-text">The user must have full access to the database</div>
|
||||
placeholder="someuser"></span>
|
||||
<div class="help-text">This user must have <strong>full access</strong> to the database</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr ng-show="fields.kind">
|
||||
<td>Password:</td>
|
||||
<td>
|
||||
<input class="form-control" type="password" ng-model="fields.password"></span>
|
||||
|
@ -404,6 +399,9 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer alert alert-warning" ng-show="databaseInvalid">
|
||||
Database Validation Issue: {{ databaseInvalid }}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary" ng-disabled="!databaseUri"
|
||||
ng-click="validateDatabase()"
|
||||
|
|
|
@ -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