]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Remove hard-coded paths from DB setup script
authorZane Bitter <zbitter@redhat.com>
Tue, 17 Apr 2012 15:38:48 +0000 (17:38 +0200)
committerZane Bitter <zbitter@redhat.com>
Tue, 17 Apr 2012 15:38:48 +0000 (17:38 +0200)
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>
bin/heat-db-setup-fedora
heat/db/sqlalchemy/manage.py [changed mode: 0644->0755]

index 00cb478586d8b1bdb1846f58c727c8df478d7521..9dc63749a170ea2a99fc15e845f05b7841d88ee1 100755 (executable)
@@ -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.
old mode 100644 (file)
new mode 100755 (executable)
index 4dffe78..a0dd923
@@ -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.'