Browse code

Do not create an unnecessary file "ml2"

Previously when running devstack with Neutron ML2 plugin,
an unnecessary file "ml2" is created in devstack directory.
It is because when the first argument is not defined the second
argument becomes the first one.

This change moves the first "options" argument of populate_ml2_config
to the last and checks the given options has a value before adding
them to a file.

Change-Id: I9ff40456798c42216d414d5f8d443e671ab7d497
Close-Bug: #1255853

Akihiro Motoki authored on 2013/11/28 16:56:51
Showing 1 changed files
... ...
@@ -34,10 +34,13 @@ Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS:-}
34 34
 ML2_L3_PLUGIN=${ML2_L3_PLUGIN:-neutron.services.l3_router.l3_router_plugin.L3RouterPlugin}
35 35
 
36 36
 function populate_ml2_config() {
37
-    OPTS=$1
38
-    CONF=$2
39
-    SECTION=$3
37
+    CONF=$1
38
+    SECTION=$2
39
+    OPTS=$3
40 40
 
41
+    if [ -z "$OPTS" ]; then
42
+        return
43
+    fi
41 44
     for I in "${OPTS[@]}"; do
42 45
         # Replace the first '=' with ' ' for iniset syntax
43 46
         iniset $CONF $SECTION ${I/=/ }
... ...
@@ -102,19 +105,17 @@ function neutron_plugin_configure_service() {
102 102
     # Since we enable the tunnel TypeDrivers, also enable a local_ip
103 103
     iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $HOST_IP
104 104
 
105
-    populate_ml2_config mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS /$Q_PLUGIN_CONF_FILE ml2
105
+    populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS
106 106
 
107
-    populate_ml2_config type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS /$Q_PLUGIN_CONF_FILE ml2
107
+    populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS
108 108
 
109
-    populate_ml2_config $Q_SRV_EXTRA_OPTS /$Q_PLUGIN_CONF_FILE ml2
109
+    populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 $Q_SRV_EXTRA_OPTS
110 110
 
111
-    populate_ml2_config $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_gre
111
+    populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_gre $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS
112 112
 
113
-    populate_ml2_config $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_vxlan
113
+    populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vxlan $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS
114 114
 
115
-    if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" != "" ]; then
116
-        populate_ml2_config $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_vlan
117
-    fi
115
+    populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vlan $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS
118 116
 }
119 117
 
120 118
 function has_neutron_plugin_security_group() {