Browse code

Neutron: Define a utility function to add neutron service class

When enabling neutron service (i.e. enable_service q-xxx), related code
unconditionally adds a necessary plugin class to Q_SERVICE_PLUGIN_CLASSES.
Which may cause duplication in Q_SERVICE_PLUGIN_CLASSES when
Q_SERVICE_PLUGIN_CLASSES is explicitly specified in localrc.
As a result, neutron server fails to start.

This patch introduces a utility function to add service class,
and check duplication.

Closes-Bug: #1261291
Change-Id: Id2880c7647babfccc3e8d9fc60dd93c4b3997ed9

Isaku Yamahata authored on 2013/12/16 15:52:03
Showing 6 changed files
... ...
@@ -744,6 +744,16 @@ function _configure_neutron_service() {
744 744
 # Utility Functions
745 745
 #------------------
746 746
 
747
+# _neutron_service_plugin_class_add() - add service plugin class
748
+function _neutron_service_plugin_class_add() {
749
+    local service_plugin_class=$1
750
+    if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
751
+        Q_SERVICE_PLUGIN_CLASSES=$service_plugin_class
752
+    elif [[ ! ,${Q_SERVICE_PLUGIN_CLASSES}, =~ ,${service_plugin_class}, ]]; then
753
+        Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$service_plugin_class"
754
+    fi
755
+}
756
+
747 757
 # _neutron_setup_rootwrap() - configure Neutron's rootwrap
748 758
 function _neutron_setup_rootwrap() {
749 759
     if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
... ...
@@ -54,11 +54,7 @@ function neutron_plugin_configure_common() {
54 54
     Q_PLUGIN_CLASS="neutron.plugins.ml2.plugin.Ml2Plugin"
55 55
     # The ML2 plugin delegates L3 routing/NAT functionality to
56 56
     # the L3 service plugin which must therefore be specified.
57
-    if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
58
-        Q_SERVICE_PLUGIN_CLASSES=$ML2_L3_PLUGIN
59
-    else
60
-        Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$ML2_L3_PLUGIN"
61
-    fi
57
+    _neutron_service_plugin_class_add $ML2_L3_PLUGIN
62 58
 }
63 59
 
64 60
 function neutron_plugin_configure_service() {
... ...
@@ -8,11 +8,7 @@ set +o xtrace
8 8
 FWAAS_PLUGIN=neutron.services.firewall.fwaas_plugin.FirewallPlugin
9 9
 
10 10
 function neutron_fwaas_configure_common() {
11
-    if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
12
-        Q_SERVICE_PLUGIN_CLASSES=$FWAAS_PLUGIN
13
-    else
14
-        Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$FWAAS_PLUGIN"
15
-    fi
11
+    _neutron_service_plugin_class_add $FWAAS_PLUGIN
16 12
 }
17 13
 
18 14
 function neutron_fwaas_configure_driver() {
... ...
@@ -19,11 +19,7 @@ function neutron_agent_lbaas_install_agent_packages() {
19 19
 }
20 20
 
21 21
 function neutron_agent_lbaas_configure_common() {
22
-    if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
23
-        Q_SERVICE_PLUGIN_CLASSES=$LBAAS_PLUGIN
24
-    else
25
-        Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$LBAAS_PLUGIN"
26
-    fi
22
+    _neutron_service_plugin_class_add $LBAAS_PLUGIN
27 23
 }
28 24
 
29 25
 function neutron_agent_lbaas_configure_agent() {
... ...
@@ -10,11 +10,7 @@ AGENT_METERING_BINARY="$NEUTRON_BIN_DIR/neutron-metering-agent"
10 10
 METERING_PLUGIN="neutron.services.metering.metering_plugin.MeteringPlugin"
11 11
 
12 12
 function neutron_agent_metering_configure_common() {
13
-    if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
14
-        Q_SERVICE_PLUGIN_CLASSES=$METERING_PLUGIN
15
-    else
16
-        Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$METERING_PLUGIN"
17
-    fi
13
+    _neutron_service_plugin_class_add $METERING_PLUGIN
18 14
 }
19 15
 
20 16
 function neutron_agent_metering_configure_agent() {
... ...
@@ -15,11 +15,7 @@ function neutron_vpn_install_agent_packages() {
15 15
 }
16 16
 
17 17
 function neutron_vpn_configure_common() {
18
-    if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
19
-        Q_SERVICE_PLUGIN_CLASSES=$VPN_PLUGIN
20
-    else
21
-        Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$VPN_PLUGIN"
22
-    fi
18
+    _neutron_service_plugin_class_add $VPN_PLUGIN
23 19
 }
24 20
 
25 21
 # Restore xtrace