From 5158486124814cbf032c0e79413c6f856225fd98 Mon Sep 17 00:00:00 2001 From: Omer Anson Date: Thu, 24 Aug 2017 17:47:37 +0300 Subject: [PATCH] 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 --- functions-common | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/functions-common b/functions-common index 660df795db..a5f770f579 100644 --- a/functions-common +++ b/functions-common @@ -1882,7 +1882,7 @@ function enable_plugin { local name=$1 local url=$2 local branch=${3:-master} - if [[ ",${DEVSTACK_PLUGINS}," =~ ,${name}, ]]; then + if is_plugin_enabled $name; then die $LINENO "Plugin attempted to be enabled twice: ${name} ${url} ${branch}" fi DEVSTACK_PLUGINS+=",$name" @@ -1891,6 +1891,19 @@ function enable_plugin { GITBRANCH[$name]=$branch } +# is_plugin_enabled +# +# Check if the plugin was enabled, e.g. using enable_plugin +# +# ``name`` The name with which the plugin was enabled +function is_plugin_enabled { + local name=$1 + if [[ ",${DEVSTACK_PLUGINS}," =~ ",${name}," ]]; then + return 0 + fi + return 1 +} + # fetch_plugins # # clones all plugins