brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [4/8] incubator-brooklyn git commit: Support multiple setup scripts in location config
Date Thu, 14 May 2015 09:59:55 GMT
Support multiple setup scripts in location config

New "setup.scripts" config which accepts an array of scripts to execute on the node.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ab9a9215
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ab9a9215
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ab9a9215

Branch: refs/heads/master
Commit: ab9a92152430cec9804d7041f9796ad42594c00d
Parents: d0cbcf3
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Wed May 13 21:52:58 2015 +0300
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Wed May 13 21:52:58 2015 +0300

----------------------------------------------------------------------
 .../location/jclouds/JcloudsLocation.java       | 24 ++++++++++++--------
 .../location/jclouds/JcloudsLocationConfig.java |  3 +++
 2 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ab9a9215/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index d0c52d8..7aa85b6 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -709,16 +709,20 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
             if (waitForSshable) {
 
                 String setupScript = setup.get(JcloudsLocationConfig.CUSTOM_MACHINE_SETUP_SCRIPT_URL);
-                if (Strings.isNonBlank(setupScript)) {
-                    customisationForLogging.add("custom setup script "+setupScript);
-
-                    String setupVarsString = setup.get(JcloudsLocationConfig.CUSTOM_MACHINE_SETUP_SCRIPT_VARS);
-                    Map<String, String> substitutions = (setupVarsString != null)
-                            ? Splitter.on(",").withKeyValueSeparator(":").split(setupVarsString)
-                            : ImmutableMap.<String, String>of();
-                    String scriptContent =  ResourceUtils.create(this).getResourceAsString(setupScript);
-                    String script = TemplateProcessor.processTemplateContents(scriptContent,
getManagementContext(), substitutions);
-                    sshMachineLocation.execCommands("Customizing node " + this, ImmutableList.of(script));
+                List<String> setupScripts = setup.get(JcloudsLocationConfig.CUSTOM_MACHINE_SETUP_SCRIPT_URL_LIST);
+                Collection<String> allScripts = new MutableList<String>().appendIfNotNull(setupScript).appendAll(setupScripts);
+                for (String setupScriptItem : allScripts) {
+                    if (Strings.isNonBlank(setupScriptItem)) {
+                        customisationForLogging.add("custom setup script "+setupScriptItem);
+
+                        String setupVarsString = setup.get(JcloudsLocationConfig.CUSTOM_MACHINE_SETUP_SCRIPT_VARS);
+                        Map<String, String> substitutions = (setupVarsString != null)
+                                ? Splitter.on(",").withKeyValueSeparator(":").split(setupVarsString)
+                                : ImmutableMap.<String, String>of();
+                        String scriptContent =  ResourceUtils.create(this).getResourceAsString(setupScriptItem);
+                        String script = TemplateProcessor.processTemplateContents(scriptContent,
getManagementContext(), substitutions);
+                        sshMachineLocation.execCommands("Customizing node " + this + " with
script " + setupScriptItem, ImmutableList.of(script));
+                    }
                 }
 
                 if (setup.get(JcloudsLocationConfig.MAP_DEV_RANDOM_TO_DEV_URANDOM)) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ab9a9215/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
index b7b61a7..15ffcfc 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
@@ -199,6 +199,9 @@ public interface JcloudsLocationConfig extends CloudLocationConfig {
     public static final ConfigKey<String> CUSTOM_MACHINE_SETUP_SCRIPT_URL = ConfigKeys.newStringConfigKey(
             "setup.script", "Custom script to customize a node");
     
+    public static final ConfigKey<List<String>> CUSTOM_MACHINE_SETUP_SCRIPT_URL_LIST
= ConfigKeys.newConfigKey(new TypeToken<List<String>>() {},
+            "setup.scripts", "A list of scripts to customize a node");
+    
     public static final ConfigKey<String> CUSTOM_MACHINE_SETUP_SCRIPT_VARS = ConfigKeys.newStringConfigKey(
             "setup.script.vars", "vars to customize a setup.script i.e.: key1:value1,key2:value2");
     


Mime
View raw message