brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [1/2] incubator-brooklyn git commit: Add install and customize commands to VanillaSoftwareProcess
Date Fri, 19 Jun 2015 11:59:54 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 9c9a86670 -> 310722dcb


Add install and customize commands to VanillaSoftwareProcess


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

Branch: refs/heads/master
Commit: 4b0d3ef92f9d880cd521df874845d3ef0ed4fb7a
Parents: 9c9a866
Author: Mike Zaccardo <mike.zaccardo@cloudsoftcorp.com>
Authored: Thu Jun 18 14:43:51 2015 -0400
Committer: Mike Zaccardo <mike.zaccardo@cloudsoftcorp.com>
Committed: Thu Jun 18 14:43:51 2015 -0400

----------------------------------------------------------------------
 .../entity/basic/AbstractVanillaProcess.java    |  4 +++-
 .../entity/basic/VanillaSoftwareProcess.java    |  3 +++
 .../basic/VanillaSoftwareProcessSshDriver.java  | 21 ++++++++++++++++++++
 .../entity/basic/VanillaWindowsProcess.java     |  4 ----
 4 files changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4b0d3ef9/software/base/src/main/java/brooklyn/entity/basic/AbstractVanillaProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/AbstractVanillaProcess.java
b/software/base/src/main/java/brooklyn/entity/basic/AbstractVanillaProcess.java
index b7f0050..2fcb3c2 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/AbstractVanillaProcess.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractVanillaProcess.java
@@ -25,7 +25,9 @@ public interface AbstractVanillaProcess extends SoftwareProcess {
     AttributeSensorAndConfigKey<String, String> DOWNLOAD_URL = SoftwareProcess.DOWNLOAD_URL;
 
     ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION,
"0.0.0");
-
+    
+    ConfigKey<String> INSTALL_COMMAND = ConfigKeys.newStringConfigKey("install.command",
"command to run during the install phase");
+    ConfigKey<String> CUSTOMIZE_COMMAND = ConfigKeys.newStringConfigKey("customize.command",
"command to run during the customization phase");
     ConfigKey<String> LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("launch.command",
"command to run to launch the process");
     ConfigKey<String> CHECK_RUNNING_COMMAND = ConfigKeys.newStringConfigKey("checkRunning.command",
"command to determine whether the process is running");
     ConfigKey<String> STOP_COMMAND = ConfigKeys.newStringConfigKey("stop.command",
"command to run to stop the process");

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4b0d3ef9/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java
b/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java
index daa112b..5b99557 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java
@@ -42,6 +42,9 @@ import brooklyn.entity.proxying.ImplementedBy;
  * </pre>
  * You can supply both {@link #DOWNLOAD_URL} and {@link #LAUNCH_COMMAND} configuration as
well..
  * <p>
+ * In addition, you can supply an {@link #INSTALL_COMMAND} and / or a {@link #CUSTOMIZE_COMMAND}
to reduce the complexity
+ * of the {@link #LAUNCH_COMMAND}, and to avoid repeating actions that are unnecessary in
subsequent launches.
+ * <p>
  * By default the PID is used to stop the process using {@code kill} followed by {@code kill
-9} if needed and restart
  * is implemented by stopping the process and then running {@link VanillaSoftwareProcessSshDriver#launch()},
but it is
  * possible to override this behavior through config keys:

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4b0d3ef9/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcessSshDriver.java
b/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcessSshDriver.java
index b3c0d26..004daa1 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcessSshDriver.java
@@ -32,6 +32,7 @@ import brooklyn.util.net.Urls;
 import brooklyn.util.os.Os;
 import brooklyn.util.ssh.BashCommands;
 import brooklyn.util.text.Identifiers;
+import brooklyn.util.text.Strings;
 
 public class VanillaSoftwareProcessSshDriver extends AbstractSoftwareProcessSshDriver implements
VanillaSoftwareProcessDriver {
 
@@ -78,6 +79,15 @@ public class VanillaSoftwareProcessSshDriver extends AbstractSoftwareProcessSshD
                     throw new IllegalStateException("Error installing archive: " + downloadedFilename);
             }
         }
+        
+        String installCommand = getEntity().getConfig(VanillaSoftwareProcess.INSTALL_COMMAND);
+        
+        if (Strings.isNonBlank(installCommand)) {
+            newScript(INSTALLING)
+                .failOnNonZeroResultCode()
+                .body.append(installCommand)
+                .execute();
+        }
     }
 
     @Override
@@ -90,6 +100,17 @@ public class VanillaSoftwareProcessSshDriver extends AbstractSoftwareProcessSshD
                     .body.append(ArchiveUtils.extractCommands(downloadedFilename, getInstallDir()))
                     .execute();
         }
+        
+        String customizeCommand = getEntity().getConfig(VanillaSoftwareProcess.CUSTOMIZE_COMMAND);
+        
+        if (Strings.isNonBlank(customizeCommand)) {
+            newScript(CUSTOMIZING)
+                .failOnNonZeroResultCode()
+                // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't
want until we start
+                .environmentVariablesReset()
+                .body.append(customizeCommand)
+                .execute();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4b0d3ef9/software/base/src/main/java/brooklyn/entity/basic/VanillaWindowsProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/VanillaWindowsProcess.java
b/software/base/src/main/java/brooklyn/entity/basic/VanillaWindowsProcess.java
index cb1f04d..a6213ac 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/VanillaWindowsProcess.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/VanillaWindowsProcess.java
@@ -48,12 +48,8 @@ public interface VanillaWindowsProcess extends AbstractVanillaProcess {
             "command to determine whether the process is running");
     ConfigKey<String> STOP_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("stop.powershell.command",
             "command to run to stop the process");
-    ConfigKey<String> CUSTOMIZE_COMMAND = ConfigKeys.newStringConfigKey("customize.command",
-            "command to run during the customization phase");
     ConfigKey<String> CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("customize.powershell.command",
             "powershell command to run during the customization phase");
-    ConfigKey<String> INSTALL_COMMAND = ConfigKeys.newStringConfigKey("install.command",
-            "command to run during the install phase");
     ConfigKey<String> INSTALL_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("install.powershell.command",
             "powershell command to run during the install phase");
     ConfigKey<Duration> REBOOT_BEGUN_TIMEOUT = ConfigKeys.newDurationConfigKey("reboot.begun.timeout",


Mime
View raw message