From 88f8558d874072536e7660a233f24207a7089651 Mon Sep 17 00:00:00 2001
From: Gary Kotton <gkotton@vmware.com>
Date: Sun, 14 Aug 2016 06:55:42 -0700
Subject: [PATCH] Enable neutron to work in a multi node setup

On the controller node where devstack is being run should create
the neutron network. The compute node should not.

The the case that we want to run a multi-node neutron setup we need
to configure the following (in the case that a plugin does not
have any agents running on the compute node):
ENABLED_SERVICES=n-cpu,neutron

In addition to this the code did not enable decomposed plugins to
configure their nova configurations if necessary.

This patch ensure that the multi-node support works.

Change-Id: I8e80edd453a1106ca666d6c531b2433be631bce4
Closes-bug: #1613069
---
 lib/neutron                     | 3 +++
 lib/neutron_plugins/services/l3 | 8 ++++++++
 stack.sh                        | 5 +----
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/neutron b/lib/neutron
index c1552e3d06..7442efd2c1 100644
--- a/lib/neutron
+++ b/lib/neutron
@@ -305,6 +305,9 @@ function configure_neutron_nova_new {
 
     iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
 
+    # optionally set options in nova_conf
+    neutron_plugin_create_nova_conf
+
     if is_service_enabled neutron-metadata-agent; then
         iniset $NOVA_CONF neutron service_metadata_proxy "True"
     fi
diff --git a/lib/neutron_plugins/services/l3 b/lib/neutron_plugins/services/l3
index a4e72483b4..334cd7a694 100644
--- a/lib/neutron_plugins/services/l3
+++ b/lib/neutron_plugins/services/l3
@@ -140,6 +140,14 @@ function _neutron_get_ext_gw_interface {
 }
 
 function create_neutron_initial_network {
+    if ! is_service_enabled q-svc && ! is_service_enabled neutron-api; then
+        echo "Controller services not enabled. No networks configured!"
+        return
+    fi
+    if [[ "$NEUTRON_CREATE_INITIAL_NETWORKS" == "False" ]]; then
+        echo "Network creation disabled!"
+        return
+    fi
     local project_id
     project_id=$(openstack project list | grep " demo " | get_field 1)
     die_if_not_set $LINENO project_id "Failure retrieving project_id for demo"
diff --git a/stack.sh b/stack.sh
index 823b63ba24..ce34cd5ef3 100755
--- a/stack.sh
+++ b/stack.sh
@@ -1248,10 +1248,7 @@ if is_service_enabled neutron; then
     start_neutron
 fi
 # Once neutron agents are started setup initial network elements
-if is_service_enabled q-svc && [[ "$NEUTRON_CREATE_INITIAL_NETWORKS" == "True" ]]; then
-    echo_summary "Creating initial neutron network elements"
-    create_neutron_initial_network
-fi
+create_neutron_initial_network
 
 if is_service_enabled nova; then
     echo_summary "Starting Nova"