Browse code

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

Sean Dague authored on 2015/03/26 18:54:28
Showing 3 changed files
... ...
@@ -1501,6 +1501,33 @@ function load_plugin_settings {
1501 1501
     done
1502 1502
 }
1503 1503
 
1504
+# plugin_override_defaults
1505
+#
1506
+# Run an extremely early setting phase for plugins that allows default
1507
+# overriding of services.
1508
+function plugin_override_defaults {
1509
+    local plugins="${DEVSTACK_PLUGINS}"
1510
+    local plugin
1511
+
1512
+    # short circuit if nothing to do
1513
+    if [[ -z $plugins ]]; then
1514
+        return
1515
+    fi
1516
+
1517
+    echo "Overriding Configuration Defaults"
1518
+    for plugin in ${plugins//,/ }; do
1519
+        local dir=${GITDIR[$plugin]}
1520
+        # source any overrides
1521
+        if [[ -f $dir/devstack/override-defaults ]]; then
1522
+            # be really verbose that an override is happening, as it
1523
+            # may not be obvious if things fail later.
1524
+            echo "$plugin has overriden the following defaults"
1525
+            cat $dir/devstack/override-defaults
1526
+            source $dir/devstack/override-defaults
1527
+        fi
1528
+    done
1529
+}
1530
+
1504 1531
 # run_plugins
1505 1532
 #
1506 1533
 # Run the devstack/plugin.sh in all the plugin directories. These are
... ...
@@ -1530,6 +1557,8 @@ function run_phase {
1530 1530
     # the source phase corresponds to settings loading in plugins
1531 1531
     if [[ "$mode" == "source" ]]; then
1532 1532
         load_plugin_settings
1533
+    elif [[ "$mode" == "override_defaults" ]]; then
1534
+        plugin_override_defaults
1533 1535
     else
1534 1536
         run_plugins $mode $phase
1535 1537
     fi
... ...
@@ -507,6 +507,10 @@ fi
507 507
 # Configure Projects
508 508
 # ==================
509 509
 
510
+# Plugin Phase 0: override_defaults - allow pluggins to override
511
+# defaults before other services are run
512
+run_phase override_defaults
513
+
510 514
 # Import apache functions
511 515
 source $TOP_DIR/lib/apache
512 516
 
... ...
@@ -45,6 +45,10 @@ fi
45 45
 # Configure Projects
46 46
 # ==================
47 47
 
48
+# Plugin Phase 0: override_defaults - allow pluggins to override
49
+# defaults before other services are run
50
+run_phase override_defaults
51
+
48 52
 # Import apache functions
49 53
 source $TOP_DIR/lib/apache
50 54