provide an override-defaults phase
during the glusterfs integration it was seen that plugins might need
to set new defaults on projects before the project files load. Create
a new override-defaults phase for that.
Intentionally not adding to the documentation yet until we're sure
this works right in the glusterfs case.
Reported-By: Deepak C Shetty <deepakcs@redhat.com>
Change-Id: I13c961b19bdcc1a99e9a7068fe91bbaac787e948
diff --git a/functions-common b/functions-common
index 48e400d..9bad981 100644
--- a/functions-common
+++ b/functions-common
@@ -1501,6 +1501,33 @@
done
}
+# plugin_override_defaults
+#
+# Run an extremely early setting phase for plugins that allows default
+# overriding of services.
+function plugin_override_defaults {
+ local plugins="${DEVSTACK_PLUGINS}"
+ local plugin
+
+ # short circuit if nothing to do
+ if [[ -z $plugins ]]; then
+ return
+ fi
+
+ echo "Overriding Configuration Defaults"
+ for plugin in ${plugins//,/ }; do
+ local dir=${GITDIR[$plugin]}
+ # source any overrides
+ if [[ -f $dir/devstack/override-defaults ]]; then
+ # be really verbose that an override is happening, as it
+ # may not be obvious if things fail later.
+ echo "$plugin has overriden the following defaults"
+ cat $dir/devstack/override-defaults
+ source $dir/devstack/override-defaults
+ fi
+ done
+}
+
# run_plugins
#
# Run the devstack/plugin.sh in all the plugin directories. These are
@@ -1530,6 +1557,8 @@
# the source phase corresponds to settings loading in plugins
if [[ "$mode" == "source" ]]; then
load_plugin_settings
+ elif [[ "$mode" == "override_defaults" ]]; then
+ plugin_override_defaults
else
run_plugins $mode $phase
fi
diff --git a/stack.sh b/stack.sh
index 9069367..a9deba7 100755
--- a/stack.sh
+++ b/stack.sh
@@ -507,6 +507,10 @@
# Configure Projects
# ==================
+# Plugin Phase 0: override_defaults - allow pluggins to override
+# defaults before other services are run
+run_phase override_defaults
+
# Import apache functions
source $TOP_DIR/lib/apache
diff --git a/unstack.sh b/unstack.sh
index a66370b..c45af74 100755
--- a/unstack.sh
+++ b/unstack.sh
@@ -45,6 +45,10 @@
# Configure Projects
# ==================
+# Plugin Phase 0: override_defaults - allow pluggins to override
+# defaults before other services are run
+run_phase override_defaults
+
# Import apache functions
source $TOP_DIR/lib/apache