brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [1/2] brooklyn-server git commit: SSH Sensor value-on-error
Date Mon, 16 Apr 2018 14:00:01 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 4236ff272 -> 30ce7faea


SSH Sensor value-on-error

Adds `value.on.error` config key to SshCommandSensor to allow a value
to be specified for use when an exception occurs when executing the
ssh command


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

Branch: refs/heads/master
Commit: 5a353b6ed41f45e43cb9bdf0ac590dc8c1613124
Parents: 4236ff2
Author: Martin Harris <github@nakomis.com>
Authored: Mon Apr 16 12:34:11 2018 +0100
Committer: Martin Harris <github@nakomis.com>
Committed: Mon Apr 16 13:10:55 2018 +0100

----------------------------------------------------------------------
 .../org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java    | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5a353b6e/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
b/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
index 84b7322..6224ed3 100644
--- a/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
+++ b/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
@@ -70,6 +70,8 @@ public final class SshCommandSensor<T> extends AbstractAddSensorFeed<T>
{
     public static final ConfigKey<String> SENSOR_EXECUTION_DIR = ConfigKeys.newStringConfigKey("executionDir",
"Directory where the command should run; "
         + "if not supplied, executes in the entity's run dir (or home dir if no run dir is
defined); "
         + "use '~' to always execute in the home dir, or 'custom-feed/' to execute in a custom-feed
dir relative to the run dir");
+    public static final ConfigKey<Object> VALUE_ON_ERROR = ConfigKeys.newConfigKey(Object.class,
"value.on.error",
+            "Value to be used if an error occurs whilst executing the ssh command", null);
     public static final MapConfigKey<Object> SENSOR_SHELL_ENVIRONMENT = BrooklynConfigKeys.SHELL_ENVIRONMENT;
 
     protected final String command;
@@ -136,7 +138,7 @@ public final class SshCommandSensor<T> extends AbstractAddSensorFeed<T>
{
                 .command(commandSupplier)
                 .suppressDuplicates(Boolean.TRUE.equals(suppressDuplicates))
                 .checkSuccess(SshValueFunctions.exitStatusEquals(0))
-                .onFailureOrException(Functions.constant((T) null))
+                .onFailureOrException(Functions.constant((T)params.get(VALUE_ON_ERROR)))
                 .onSuccess(Functions.compose(new Function<String, T>() {
                         @Override
                         public T apply(String input) {


Mime
View raw message