Browse code

lib/neutron: Create initial topology only on controller node

To avoid it being created multiple times for multinode setup.

Note: This reverts "Enable neutron to work in a multi node setup"
(commit 88f8558d874072536e7660a233f24207a7089651) partly and fixes
the issue differently.
The configuration in question uses the new lib/neutron. (not neutron-legacy)
In that case, calling create_neutron_initial_network from stack.sh directly
is a wrong way, as create_neutron_initial_network is sourced by
neutron-legacy. The new neutron code should not rely on the legacy one.

Closes-Bug: #1613069
Change-Id: I868afeb065d80d8ccd57630b90658e330ab94251

YAMAMOTO Takashi authored on 2016/10/20 04:21:00
Showing 3 changed files
... ...
@@ -431,15 +431,17 @@ function start_neutron_new {
431 431
     if is_service_enabled neutron-l3; then
432 432
         run_process neutron-l3 "$NEUTRON_BIN_DIR/$NEUTRON_L3_BINARY $NEUTRON_CONFIG_ARG"
433 433
     fi
434
-    # XXX(sc68cal) - Here's where plugins can wire up their own networks instead
435
-    # of the code in lib/neutron_plugins/services/l3
436
-    if type -p neutron_plugin_create_initial_networks > /dev/null; then
437
-        neutron_plugin_create_initial_networks
438
-    else
439
-        # XXX(sc68cal) Load up the built in Neutron networking code and build a topology
440
-        source $TOP_DIR/lib/neutron_plugins/services/l3
441
-        # Create the networks using servic
442
-        create_neutron_initial_network
434
+    if is_service_enabled neutron-api; then
435
+        # XXX(sc68cal) - Here's where plugins can wire up their own networks instead
436
+        # of the code in lib/neutron_plugins/services/l3
437
+        if type -p neutron_plugin_create_initial_networks > /dev/null; then
438
+            neutron_plugin_create_initial_networks
439
+        else
440
+            # XXX(sc68cal) Load up the built in Neutron networking code and build a topology
441
+            source $TOP_DIR/lib/neutron_plugins/services/l3
442
+            # Create the networks using servic
443
+            create_neutron_initial_network
444
+        fi
443 445
     fi
444 446
     if is_service_enabled neutron-metadata-agent; then
445 447
         run_process neutron-metadata-agent "$NEUTRON_BIN_DIR/$NEUTRON_META_BINARY $NEUTRON_CONFIG_ARG"
... ...
@@ -154,14 +154,6 @@ function _neutron_get_ext_gw_interface {
154 154
 }
155 155
 
156 156
 function create_neutron_initial_network {
157
-    if ! is_service_enabled q-svc && ! is_service_enabled neutron-api; then
158
-        echo "Controller services not enabled. No networks configured!"
159
-        return
160
-    fi
161
-    if [[ "$NEUTRON_CREATE_INITIAL_NETWORKS" == "False" ]]; then
162
-        echo "Network creation disabled!"
163
-        return
164
-    fi
165 157
     local project_id
166 158
     project_id=$(openstack project list | grep " demo " | get_field 1)
167 159
     die_if_not_set $LINENO project_id "Failure retrieving project_id for demo"
... ...
@@ -1267,7 +1267,10 @@ if is_service_enabled neutron; then
1267 1267
     start_neutron
1268 1268
 fi
1269 1269
 # Once neutron agents are started setup initial network elements
1270
-create_neutron_initial_network
1270
+if is_service_enabled q-svc && [[ "$NEUTRON_CREATE_INITIAL_NETWORKS" == "True" ]]; then
1271
+    echo_summary "Creating initial neutron network elements"
1272
+    create_neutron_initial_network
1273
+fi
1271 1274
 
1272 1275
 if is_service_enabled nova; then
1273 1276
     echo_summary "Starting Nova"