From c2ab4a39d136949db5d2e6c6c2b90930929fe087 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Tue, 17 Apr 2012 17:38:48 +0200 Subject: [PATCH] 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 --- bin/heat-db-setup-fedora | 13 ++----------- heat/db/sqlalchemy/manage.py | 6 +++++- 2 files changed, 7 insertions(+), 12 deletions(-) mode change 100644 => 100755 heat/db/sqlalchemy/manage.py diff --git a/bin/heat-db-setup-fedora b/bin/heat-db-setup-fedora index 00cb4785..9dc63749 100755 --- a/bin/heat-db-setup-fedora +++ b/bin/heat-db-setup-fedora @@ -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. diff --git a/heat/db/sqlalchemy/manage.py b/heat/db/sqlalchemy/manage.py old mode 100644 new mode 100755 index 4dffe783..a0dd923a --- a/heat/db/sqlalchemy/manage.py +++ b/heat/db/sqlalchemy/manage.py @@ -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.' -- 2.45.2