Browse code

Add function is_plugin_enabled

Add a function which tests if a plugin has been enabled with
enable_plugin. This is helpful if two co-ordinating projects want to run
specific setup in devstack in one only if the other is enabled.

Change-Id: Ibf113755595b19d028374cdc1c86e19b5170be4f

Omer Anson authored on 2017/08/24 23:47:37
Showing 1 changed files
... ...
@@ -1882,7 +1882,7 @@ function enable_plugin {
1882 1882
     local name=$1
1883 1883
     local url=$2
1884 1884
     local branch=${3:-master}
1885
-    if [[ ",${DEVSTACK_PLUGINS}," =~ ,${name}, ]]; then
1885
+    if is_plugin_enabled $name; then
1886 1886
         die $LINENO "Plugin attempted to be enabled twice: ${name} ${url} ${branch}"
1887 1887
     fi
1888 1888
     DEVSTACK_PLUGINS+=",$name"
... ...
@@ -1891,6 +1891,19 @@ function enable_plugin {
1891 1891
     GITBRANCH[$name]=$branch
1892 1892
 }
1893 1893
 
1894
+# is_plugin_enabled <name>
1895
+#
1896
+# Check if the plugin was enabled, e.g. using enable_plugin
1897
+#
1898
+# ``name`` The name with which the plugin was enabled
1899
+function is_plugin_enabled {
1900
+    local name=$1
1901
+    if [[ ",${DEVSTACK_PLUGINS}," =~ ",${name}," ]]; then
1902
+        return 0
1903
+    fi
1904
+    return 1
1905
+}
1906
+
1894 1907
 # fetch_plugins
1895 1908
 #
1896 1909
 # clones all plugins