From 21d84c29b22fb69b00739ae40d69f80d5182a94e Mon Sep 17 00:00:00 2001
From: "John L. Villalovos" <john.l.villalovos@intel.com>
Date: Fri, 11 Nov 2016 15:26:11 -0800
Subject: [PATCH] If plugin is enabled multiple times fail

When using the enable_plugin command and grenade jobs it can be
easy to enable the same plugin twice, as the grenade job has a
registration section and the configuration in project-config can also
enable it due to code-reuse in project-config.

If a plugin is enabled twice it will likely fail, though it won't be
obvious that it was due to the plugin being enabled multiple times.

This change makes it so if it sees the same plugin name is enabled
more than once it will die and an error message outputted.

Change-Id: I9f1d7e58b861b04473b6a57c9ad404203fb7277a
---
 functions-common | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/functions-common b/functions-common
index 87e6bb453d..eeced621a9 100644
--- a/functions-common
+++ b/functions-common
@@ -1767,6 +1767,9 @@ function enable_plugin {
     local name=$1
     local url=$2
     local branch=${3:-master}
+    if [[ ",${DEVSTACK_PLUGINS}," =~ ,${name}, ]]; then
+        die $LINENO "Plugin attempted to be enabled twice: ${name} ${url} ${branch}"
+    fi
     DEVSTACK_PLUGINS+=",$name"
     GITREPO[$name]=$url
     GITDIR[$name]=$DEST/$name