Browse code

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

Salvatore Orlando authored on 2013/08/06 00:56:17
Showing 2 changed files
... ...
@@ -367,7 +367,9 @@ function create_neutron_initial_network() {
367 367
 
368 368
 # init_neutron() - Initialize databases, etc.
369 369
 function init_neutron() {
370
-    :
370
+    recreate_database $Q_DB_NAME utf8
371
+    # Run Neutron db migrations
372
+    $NEUTRON_BIN_DIR/neutron-db-manage --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE upgrade head
371 373
 }
372 374
 
373 375
 # install_neutron() - Collect source and prepare
... ...
@@ -614,12 +616,6 @@ function _configure_neutron_service() {
614 614
     cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
615 615
     cp $NEUTRON_DIR/etc/policy.json $Q_POLICY_FILE
616 616
 
617
-    if is_service_enabled $DATABASE_BACKENDS; then
618
-        recreate_database $Q_DB_NAME utf8
619
-    else
620
-        die $LINENO "A database must be enabled in order to use the $Q_PLUGIN Neutron plugin."
621
-    fi
622
-
623 617
     # Update either configuration file with plugin
624 618
     iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
625 619
 
... ...
@@ -939,7 +939,10 @@ if is_service_enabled neutron; then
939 939
     echo_summary "Configuring Neutron"
940 940
 
941 941
     configure_neutron
942
-    init_neutron
942
+    # Run init_neutron only on the node hosting the neutron API server
943
+    if is_service_enabled $DATABASE_BACKENDS && is_service_enabled q-svc; then
944
+        init_neutron
945
+    fi
943 946
 fi
944 947
 
945 948
 # Some Neutron plugins require network controllers which are not