From 8bbf61f5097dee459a4f05681e7f22a7e4e44ee2 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Fri, 20 Feb 2015 06:28:21 +1100 Subject: [PATCH] Handle the rename of the versions directory. We still need to handle testing the API database as well at some point, but for now just handle that there are two possible places that the cell db could be. Change-Id: I6f718d7037d7b01ccb772013ad367367a66f82e5 Closes-Bug: 1423662 --- .../real_db_upgrade/handle_results.py | 17 ++++++++++++++--- .../real_db_upgrade/nova_mysql_migrations.sh | 12 ++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/turbo_hipster/task_plugins/real_db_upgrade/handle_results.py b/turbo_hipster/task_plugins/real_db_upgrade/handle_results.py index 561898f..4c02fb7 100644 --- a/turbo_hipster/task_plugins/real_db_upgrade/handle_results.py +++ b/turbo_hipster/task_plugins/real_db_upgrade/handle_results.py @@ -44,10 +44,21 @@ class LogParser(object): def find_schemas(self): """Return a list of the schema numbers present in git.""" + + # TODO(mikal): once more of the cells code lands this needs to handle + # the API migratons as well as the cells migration. Just do cells for + # now though. + cells_migration_path = os.path.join( + self.gitpath, + 'nova/db/sqlalchemy/cell_migrations/migrate_repo/versions') + + if not os.path.exists(cells_migration_path): + cells_migration_path = os.path.join( + self.gitpath, + 'nova/db/sqlalchemy/migrate_repo/versions') + return [int(MIGRATION_NUMBER_RE.findall(f)[0]) for f in os.listdir( - os.path.join(self.gitpath, - 'nova/db/sqlalchemy/migrate_repo/versions')) - if MIGRATION_NUMBER_RE.match(f)] + cells_migration_path) if MIGRATION_NUMBER_RE.match(f)] def process_log(self): """Analyse a log for errors.""" diff --git a/turbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh b/turbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh index 83893cc..28cf54b 100755 --- a/turbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh +++ b/turbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh @@ -74,9 +74,17 @@ EOF python setup.py -q develop python setup.py -q install + # Find where we store db versions + # TODO(mikal): note this only handles the cell db for now + versions_path="$GIT_REPO_PATH/nova/db/sqlalchemy/cell_migrations/migrate_repo/versions" + if [ ! -e $versions_path ] + then + versions_path="$GIT_REPO_PATH/nova/db/sqlalchemy/migrate_repo/versions" + fi + # Log the migrations present echo "Migrations present:" - ls $GIT_REPO_PATH/nova/db/sqlalchemy/migrate_repo/versions/*.py | sed 's/.*\///' | egrep "^[0-9]+_" + ls $versions_path/*.py | sed 's/.*\///' | egrep "^[0-9]+_" # Flush innodb's caches echo "Restarting mysql" @@ -90,7 +98,7 @@ EOF if [ "%$2%" == "%%" ] then - end_version=`ls $GIT_REPO_PATH/nova/db/sqlalchemy/migrate_repo/versions/*.py | sed 's/.*\///' | egrep "^[0-9]+_" | tail -1 | cut -f 1 -d "_"` + end_version=`ls $versions_path/*.py | sed 's/.*\///' | egrep "^[0-9]+_" | tail -1 | cut -f 1 -d "_"` else end_version=$2 fi