Browse code

Merge "Add the ability to install/enable Heat plugins"

Jenkins authored on 2015/10/30 10:19:46
Showing 1 changed files
... ...
@@ -69,6 +69,8 @@ else
69 69
     HEAT_STACK_DOMAIN=$(trueorfalse True HEAT_STACK_DOMAIN)
70 70
     HEAT_DEFERRED_AUTH=${HEAT_DEFERRED_AUTH:-trusts}
71 71
 fi
72
+HEAT_PLUGIN_DIR=${HEAT_PLUGIN_DIR:-$DATA_DIR/heat/plugins}
73
+ENABLE_HEAT_PLUGINS=${ENABLE_HEAT_PLUGINS:-}
72 74
 
73 75
 # Functions
74 76
 # ---------
... ...
@@ -188,6 +190,35 @@ function configure_heat {
188 188
     # copy the default templates
189 189
     cp $HEAT_DIR/etc/heat/templates/* $HEAT_TEMPLATES_DIR/
190 190
 
191
+    # Enable heat plugins.
192
+    # NOTE(nic): The symlink nonsense is necessary because when
193
+    # plugins are installed in "developer mode", the final component
194
+    # of their target directory is always "resources", which confuses
195
+    # Heat's plugin loader into believing that all plugins are named
196
+    # "resources", and therefore are all the same plugin; so it
197
+    # will only load one of them.  Linking them all to a common
198
+    # location with unique names avoids that type of collision,
199
+    # while still allowing the plugins to be edited in-tree.
200
+    local err_count=0
201
+
202
+    if [ -n "$ENABLE_HEAT_PLUGINS" ]; then
203
+        mkdir -p $HEAT_PLUGIN_DIR
204
+        # Clean up cruft from any previous runs
205
+        rm -f $HEAT_PLUGIN_DIR/*
206
+        iniset $HEAT_CONF DEFAULT plugin_dirs $HEAT_PLUGIN_DIR
207
+    fi
208
+
209
+    for heat_plugin in $ENABLE_HEAT_PLUGINS; do
210
+        if [ -d $HEAT_DIR/contrib/$heat_plugin ]; then
211
+            setup_package $HEAT_DIR/contrib/$heat_plugin -e
212
+            ln -s $HEAT_DIR/contrib/$heat_plugin/$heat_plugin/resources $HEAT_PLUGIN_DIR/$heat_plugin
213
+        else
214
+            : # clear retval on the test so that we can roll up errors
215
+            err $LINENO "Requested Heat plugin(${heat_plugin}) not found."
216
+            err_count=$(($err_count + 1))
217
+        fi
218
+    done
219
+    [ $err_count -eq 0 ] || die $LINENO "$err_count of the requested Heat plugins could not be installed."
191 220
 }
192 221
 
193 222
 # init_heat() - Initialize database