Optional database prepare

In some cases nailgun database could already exist
and ready for use. In this case we don't need
to do anything when preparing database.

Change-Id: I865eefd44af0dd1062f27b789d60515d55d7b4d2
This commit is contained in:
Vladimir Kozhukalov 2016-06-10 15:01:31 +03:00
parent f121a0c322
commit a22aee3396
3 changed files with 16 additions and 6 deletions

View File

@ -25,14 +25,22 @@ case $1 in
cleanup_nailgun_env
;;
prepare_nailgun_database)
prepare_pgpass
prepare_database_role
prepare_database
if [[ "${NAILGUN_DB_PREPARE}" == "yes" ]]; then
prepare_pgpass
prepare_database_role
prepare_database
else
echo "Preparing database has been skipped due to NAILGUN_DB_PREPARE=${NAILGUN_DB_PREPARE}"
fi
;;
cleanup_nailgun_database)
prepare_pgpass
cleanup_database
cleanup_pgpass
if [[ "${NAILGUN_DB_PREPARE}" == "yes" ]]; then
prepare_pgpass
cleanup_database
cleanup_pgpass
else
echo "Cleaning up database has been skipped due to NAILGUN_DB_PREPARE=${NAILGUN_DB_PREPARE}"
fi
;;
cleanup_nailgun_server)
cleanup_server

View File

@ -66,6 +66,7 @@ EOL
}
prepare_server() {
python ${NAILGUN_ROOT}/manage.py dropdb > /dev/null
python ${NAILGUN_ROOT}/manage.py syncdb > /dev/null
python ${NAILGUN_ROOT}/manage.py loaddefault > /dev/null
if test -n "$NAILGUN_FIXTURE_FILES"; then

View File

@ -15,6 +15,7 @@ setenv =
DB_ROOTPW={env:DB_ROOTPW:insecure_slave}
DB_ROOTPGPASS={[base]ARTS}/pgpass
NAILGUN_DB_PREPARE={env:NAILGUN_DB_PREPARE:yes}
NAILGUN_DB={env:NAILGUN_DB:openstack_citest}
NAILGUN_DB_HOST={env:NAILGUN_DB_HOST:127.0.0.1}
NAILGUN_DB_PORT={env:NAILGUN_DB_PORT:5432}