Browse code

Update the ML2 configuration in devstack

This commit adds support to devstack to set ML2 options including
MechanismDrivers, TypeDrivers, and TypeDriver specific configuration for ML2
when running with devstack.

This also allows for simple configuration of VLAN, GRE, and VXLAN ML2 devstack
setups with the OVS agent as follows:

# VLAN configuration
Q_PLUGIN=ml2
ENABLE_TENANT_VLANS=True

# GRE tunnel configuration
Q_PLUGIN=ml2
ENABLE_TENANT_TUNNELS=True

# VXLAN tunnel configuration
Q_PLUGIN=ml2
Q_ML2_TENANT_NETWORK_TYPE=vxlan

Fixes bug 1200767

Change-Id: Ib16efac13440b5d50658a0e6be35bc735510a262

Kyle Mestery authored on 2013/07/19 23:26:53
Showing 2 changed files
... ...
@@ -148,6 +148,32 @@ An example of using the variables in your `localrc` is below:
148 148
     Q_AGENT_EXTRA_AGENT_OPTS=(tunnel_type=vxlan vxlan_udp_port=8472)
149 149
     Q_SRV_EXTRA_OPTS=(tenant_network_type=vxlan)
150 150
 
151
+devstack also supports configuring the Neutron ML2 plugin. The ML2 plugin can run with the OVS, LinuxBridge, or Hyper-V agents on compute hosts. A simple way to configure the ml2 plugin is shown below:
152
+
153
+    # VLAN configuration
154
+    Q_PLUGIN=ml2
155
+    ENABLE_TENANT_VLANS=True
156
+
157
+    # GRE tunnel configuration
158
+    Q_PLUGIN=ml2
159
+    ENABLE_TENANT_TUNNELS=True
160
+
161
+    # VXLAN tunnel configuration
162
+    Q_PLUGIN=ml2
163
+    Q_ML2_TENANT_NETWORK_TYPE=vxlan
164
+
165
+The above will default in devstack to using the OVS on each compute host. To change this, set the `Q_AGENT` variable to the agent you want to run (e.g. linuxbridge).
166
+
167
+    Variable Name                    Notes
168
+    -------------------------------------------------------------------------------------
169
+    Q_AGENT                          This specifies which agent to run with the ML2 Plugin (either `openvswitch` or `linuxbridge`).
170
+    Q_ML2_PLUGIN_MECHANISM_DRIVERS   The ML2 MechanismDrivers to load. The default is none. Note, ML2 will work with the OVS and LinuxBridge agents by default.
171
+    Q_ML2_PLUGIN_TYPE_DRIVERS        The ML2 TypeDrivers to load. Defaults to all available TypeDrivers.
172
+    Q_ML2_PLUGIN_GRE_TYPE_OPTIONS    GRE TypeDriver options. Defaults to none.
173
+    Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS  VXLAN TypeDriver options. Defaults to none.
174
+    Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS   VLAN TypeDriver options. Defaults to none.
175
+    Q_AGENT_EXTRA_AGENT_OPTS         Extra configuration options to pass to the OVS or LinuxBridge Agent.
176
+
151 177
 # Tempest
152 178
 
153 179
 If tempest has been successfully configured, a basic set of smoke tests can be run as follows:
... ...
@@ -5,10 +5,42 @@
5 5
 MY_XTRACE=$(set +o | grep xtrace)
6 6
 set +o xtrace
7 7
 
8
+# Enable this to simply and quickly enable tunneling with ML2.
9
+# Select either 'gre', 'vxlan', or '(gre vxlan)'
10
+Q_ML2_TENANT_NETWORK_TYPE=${Q_ML2_TENANT_NETWORK_TYPE:-}
11
+# This has to be set here since the agent will set this in the config file
12
+if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "" ]]; then
13
+    Q_AGENT_EXTRA_AGENT_OPTS=(tunnel_types=$Q_ML2_TENANT_NETWORK_TYPE)
14
+elif [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
15
+    Q_AGENT_EXTRA_AGENT_OPTS=(tunnel_types=gre)
16
+fi
17
+
8 18
 # Default openvswitch L2 agent
9 19
 Q_AGENT=${Q_AGENT:-openvswitch}
10 20
 source $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent
11 21
 
22
+# List of MechanismDrivers to load
23
+Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_PLUGIN_MECHANISM_DRIVERS:-}
24
+# List of Type Drivers to load
25
+Q_ML2_PLUGIN_TYPE_DRIVERS=${Q_ML2_PLUGIN_TYPE_DRIVERS:-local,flat,vlan,gre,vxlan}
26
+# Default GRE TypeDriver options
27
+Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GRE_TYPE_OPTIONS:-tunnel_id_ranges=$TENANT_TUNNEL_RANGES}
28
+# Default VXLAN TypeDriver options
29
+Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS:-vni_ranges=1001:2000}
30
+# Default VLAN TypeDriver options
31
+Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS:-}
32
+
33
+function populate_ml2_config() {
34
+    OPTS=$1
35
+    CONF=$2
36
+    SECTION=$3
37
+
38
+    for I in "${OPTS[@]}"; do
39
+        # Replace the first '=' with ' ' for iniset syntax
40
+        iniset $CONF $SECTION ${I/=/ }
41
+    done
42
+}
43
+
12 44
 function neutron_plugin_configure_common() {
13 45
     Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ml2
14 46
     Q_PLUGIN_CONF_FILENAME=ml2_conf.ini
... ...
@@ -17,26 +49,31 @@ function neutron_plugin_configure_common() {
17 17
 }
18 18
 
19 19
 function neutron_plugin_configure_service() {
20
-    if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
21
-        iniset /$Q_PLUGIN_CONF_FILE ml2 tenant_network_types gre
22
-        iniset /$Q_PLUGIN_CONF_FILE ml2_type_gre tunnel_id_ranges $TENANT_TUNNEL_RANGES
20
+    if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "" ]]; then
21
+        Q_SRV_EXTRA_OPTS=(tenant_network_types=$Q_ML2_TENANT_NETWORK_TYPE)
22
+    elif [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
23
+        # This assumes you want a simple configuration, and will overwrite
24
+        # Q_SRV_EXTRA_OPTS if set in addition to ENABLE_TENANT_TUNNELS.
25
+        Q_SRV_EXTRA_OPTS=(tenant_network_types=gre)
26
+        Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=(tunnel_id_ranges=$TENANT_TUNNEL_RANGES)
23 27
     elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
24
-        iniset /$Q_PLUGIN_CONF_FILE ml2 tenant_network_types vlan
28
+        Q_SRV_EXTRA_OPTS=(tenant_network_types=vlan)
25 29
     else
26 30
         echo "WARNING - The ml2 plugin is using local tenant networks, with no connectivity between hosts."
27 31
     fi
28 32
 
29
-    # Override ``ML2_VLAN_RANGES`` and any needed agent configuration
30
-    # variables in ``localrc`` for more complex physical network
31
-    # configurations.
32
-    if [[ "$ML2_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
33
-        ML2_VLAN_RANGES=$PHYSICAL_NETWORK
34
-        if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
35
-            ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE
33
+    # Allow for overrding VLAN configuration (for example, to configure provider
34
+    # VLANs) by first checking if Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS is set.
35
+    if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" == "" ]; then
36
+        if [[ "$ML2_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
37
+            ML2_VLAN_RANGES=$PHYSICAL_NETWORK
38
+            if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
39
+                ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE
40
+            fi
41
+        fi
42
+        if [[ "$ML2_VLAN_RANGES" != "" ]]; then
43
+            Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=(network_vlan_ranges=$ML2_VLAN_RANGES)
36 44
         fi
37
-    fi
38
-    if [[ "$ML2_VLAN_RANGES" != "" ]]; then
39
-        iniset /$Q_PLUGIN_CONF_FILE ml2_type_vlan network_vlan_ranges $ML2_VLAN_RANGES
40 45
     fi
41 46
 
42 47
     # REVISIT(rkukura): Setting firewall_driver here for
... ...
@@ -52,6 +89,20 @@ function neutron_plugin_configure_service() {
52 52
         iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver neutron.agent.firewall.NoopFirewallDriver
53 53
     fi
54 54
 
55
+    # Since we enable the tunnel TypeDrivers, also enable a local_ip
56
+    iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $HOST_IP
57
+
58
+    populate_ml2_config type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS /$Q_PLUGIN_CONF_FILE ml2
59
+
60
+    populate_ml2_config $Q_SRV_EXTRA_OPTS /$Q_PLUGIN_CONF_FILE ml2
61
+
62
+    populate_ml2_config $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_gre
63
+
64
+    populate_ml2_config $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_vxlan
65
+
66
+    if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" != "" ]; then
67
+        populate_ml2_config $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_vlan
68
+    fi
55 69
 }
56 70
 
57 71
 function has_neutron_plugin_security_group() {