Remove hard-coded paths from DB setup script

Since versions of heat can and will change, we do not want want them
hard-coded in the DB setup script. Instead, use the Python import logic to
determine the location of the module.

This will use the local copy of heat (which is usually what you want) if
run from the top level of the repository. Otherwise it will use the
installed version, as determined by Python.

Signed-off-by: Zane Bitter <zbitter@redhat.com>
This commit is contained in:
Zane Bitter 2012-04-17 17:38:48 +02:00
parent d4fda02735
commit c2ab4a39d1
2 changed files with 7 additions and 12 deletions

View File

@ -213,17 +213,8 @@ if [ "${MYSQL_HEAT_PW}" != "${MYSQL_HEAT_PW_DEFAULT}" ] ; then
sed -i -e "s/mysql:\/\/heat:\(.*\)@/mysql:\/\/heat:${MYSQL_HEAT_PW}@/" ${HEAT_CONFIG}
fi
# Create the schema using sqlalchemy-migrate
if [ "$1" = "rpm" ]
then
pushd /usr/lib/python2.7/site-packages/heat/db/sqlalchemy
else
pushd /usr/lib/python2.7/site-packages/heat-0.0.1-py2.7.egg/heat/db/sqlalchemy/
fi
python manage.py version_control
python manage.py upgrade
popd
python -m heat.db.sqlalchemy.manage version_control
python -m heat.db.sqlalchemy.manage upgrade
# Do a final sanity check on the database.

6
heat/db/sqlalchemy/manage.py Normal file → Executable file
View File

@ -3,8 +3,12 @@ from migrate.versioning.shell import main
import migrate.exceptions
if __name__ == '__main__':
import os.path
migrate_repo_path = os.path.join(os.path.dirname(__file__),
'migrate_repo')
try:
main(url='mysql://heat:heat@localhost/heat', debug='False',
repository='migrate_repo')
repository=migrate_repo_path)
except migrate.exceptions.DatabaseAlreadyControlledError:
print 'Database already version controlled.'