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
diff --git a/lib/neutron b/lib/neutron
index b05b16d..3808165 100644
--- a/lib/neutron
+++ b/lib/neutron
@@ -744,6 +744,16 @@
 # Utility Functions
 #------------------
 
+# _neutron_service_plugin_class_add() - add service plugin class
+function _neutron_service_plugin_class_add() {
+    local service_plugin_class=$1
+    if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
+        Q_SERVICE_PLUGIN_CLASSES=$service_plugin_class
+    elif [[ ! ,${Q_SERVICE_PLUGIN_CLASSES}, =~ ,${service_plugin_class}, ]]; then
+        Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$service_plugin_class"
+    fi
+}
+
 # _neutron_setup_rootwrap() - configure Neutron's rootwrap
 function _neutron_setup_rootwrap() {
     if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then