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:
parent
f86d2e1a05
commit
0eec4f86c1
10
lib/database
10
lib/database
@ -101,7 +101,7 @@ function initialize_database_backends {
|
|||||||
# a multi-node DevStack installation.
|
# a multi-node DevStack installation.
|
||||||
|
|
||||||
# NOTE: Don't specify ``/db`` in this string so we can use it for multiple services
|
# 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
|
return 0
|
||||||
}
|
}
|
||||||
@ -135,14 +135,6 @@ function database_connection_url {
|
|||||||
database_connection_url_$DATABASE_TYPE $db
|
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
|
# Restore xtrace
|
||||||
$XTRACE
|
$XTRACE
|
||||||
|
@ -12,12 +12,6 @@ MY_XTRACE=$(set +o | grep xtrace)
|
|||||||
set +o xtrace
|
set +o xtrace
|
||||||
|
|
||||||
MYSQL_DRIVER=${MYSQL_DRIVER:-PyMySQL}
|
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
|
register_database mysql
|
||||||
|
|
||||||
@ -30,6 +24,14 @@ fi
|
|||||||
# Functions
|
# 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
|
# Get rid of everything enough to cleanly change database backends
|
||||||
function cleanup_database_mysql {
|
function cleanup_database_mysql {
|
||||||
stop_service $MYSQL
|
stop_service $MYSQL
|
||||||
|
@ -21,6 +21,10 @@ register_database postgresql
|
|||||||
# Functions
|
# Functions
|
||||||
# ---------
|
# ---------
|
||||||
|
|
||||||
|
function get_database_type_postgresql {
|
||||||
|
echo postgresql
|
||||||
|
}
|
||||||
|
|
||||||
# Get rid of everything enough to cleanly change database backends
|
# Get rid of everything enough to cleanly change database backends
|
||||||
function cleanup_database_postgresql {
|
function cleanup_database_postgresql {
|
||||||
stop_service postgresql
|
stop_service postgresql
|
||||||
|
Loading…
Reference in New Issue
Block a user