database: fix PostgreSQL connection string

If all databases drivers are loaded, MySQL SQLAlchemy driver
overrides all the other one that might not have set one.
This patches fixes that.

Change-Id: If6d8d08e5b7b7c48ca012677b536d71058def6fd
Closes-Bug: #1493304
This commit is contained in:
Julien Danjou 2015-09-08 10:45:06 +00:00
parent f86d2e1a05
commit 0eec4f86c1
3 changed files with 13 additions and 15 deletions

View File

@ -101,7 +101,7 @@ function initialize_database_backends {
# a multi-node DevStack installation.
# NOTE: Don't specify ``/db`` in this string so we can use it for multiple services
BASE_SQL_CONN=${BASE_SQL_CONN:-$(get_database_type)://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST}
BASE_SQL_CONN=${BASE_SQL_CONN:-$(get_database_type_$DATABASE_TYPE)://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST}
return 0
}
@ -135,14 +135,6 @@ function database_connection_url {
database_connection_url_$DATABASE_TYPE $db
}
function get_database_type {
if [[ -n "${SQLALCHEMY_DATABASE_DRIVER}" ]]; then
echo "${DATABASE_TYPE}+${SQLALCHEMY_DATABASE_DRIVER}"
else
echo "${DATABASE_TYPE}"
fi
}
# Restore xtrace
$XTRACE

View File

@ -12,12 +12,6 @@ MY_XTRACE=$(set +o | grep xtrace)
set +o xtrace
MYSQL_DRIVER=${MYSQL_DRIVER:-PyMySQL}
# Force over to pymysql driver by default if we are using it.
if is_service_enabled mysql; then
if [[ "$MYSQL_DRIVER" == "PyMySQL" ]]; then
SQLALCHEMY_DATABASE_DRIVER=${SQLALCHEMY_DATABASE_DRIVER:-"pymysql"}
fi
fi
register_database mysql
@ -30,6 +24,14 @@ fi
# Functions
# ---------
function get_database_type_mysql {
if [[ "$MYSQL_DRIVER" == "PyMySQL" ]]; then
echo mysql+pymysql
else
echo mysql
fi
}
# Get rid of everything enough to cleanly change database backends
function cleanup_database_mysql {
stop_service $MYSQL

View File

@ -21,6 +21,10 @@ register_database postgresql
# Functions
# ---------
function get_database_type_postgresql {
echo postgresql
}
# Get rid of everything enough to cleanly change database backends
function cleanup_database_postgresql {
stop_service postgresql