From dd64988ff4c0a174691cc7d45e3eaef8acdc4fc8 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 5 Aug 2013 08:56:17 -0700 Subject: [PATCH] Run Neutron migrations after creating schema Partial-Bug 1207402 This patch executes Neutron DB migrations (based on alembic) before starting the Neutron services, similar to what happens for most of other openstack projects managed by devstack. This will ensure devstack always creates correctly version-stamped Neutron databases. Change-Id: Ia941c426a1563bcc4cb5eae64ea30c0bf7677220 --- lib/neutron | 10 +++------- stack.sh | 5 ++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/neutron b/lib/neutron index 835f900425..c546f378b0 100644 --- a/lib/neutron +++ b/lib/neutron @@ -367,7 +367,9 @@ function create_neutron_initial_network() { # init_neutron() - Initialize databases, etc. function init_neutron() { - : + recreate_database $Q_DB_NAME utf8 + # Run Neutron db migrations + $NEUTRON_BIN_DIR/neutron-db-manage --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE upgrade head } # install_neutron() - Collect source and prepare @@ -614,12 +616,6 @@ function _configure_neutron_service() { cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE cp $NEUTRON_DIR/etc/policy.json $Q_POLICY_FILE - if is_service_enabled $DATABASE_BACKENDS; then - recreate_database $Q_DB_NAME utf8 - else - die $LINENO "A database must be enabled in order to use the $Q_PLUGIN Neutron plugin." - fi - # Update either configuration file with plugin iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS diff --git a/stack.sh b/stack.sh index 5ba60d2430..01f948e6b7 100755 --- a/stack.sh +++ b/stack.sh @@ -939,7 +939,10 @@ if is_service_enabled neutron; then echo_summary "Configuring Neutron" configure_neutron - init_neutron + # Run init_neutron only on the node hosting the neutron API server + if is_service_enabled $DATABASE_BACKENDS && is_service_enabled q-svc; then + init_neutron + fi fi # Some Neutron plugins require network controllers which are not