public class ScriptHelper
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
ScriptPart | 
body  | 
ScriptPart | 
footer  | 
ScriptPart | 
header  | 
static org.slf4j.Logger | 
log  | 
java.lang.String | 
summary  | 
| Constructor and Description | 
|---|
ScriptHelper(NaiveScriptRunner runner,
            java.lang.String summary)  | 
| Modifier and Type | Method and Description | 
|---|---|
ScriptHelper | 
closeSshConnection()
The connection should be closed and disconnected once the commands have executed. 
 | 
ScriptHelper | 
environmentVariablesReset()
ensures the script runs with no environment variables; 
 by default they will be inherited from the entity/driver (eg getShellEnvironment()) 
 | 
ScriptHelper | 
environmentVariablesReset(java.util.Map<?,?> envVarsToSet)
overrides the default environment variables to use the given set; 
 by default "env" is inherited from the entity/driver (eg getShellEnvironment());
 TODO would be nice to have a way to add just a few, 
 but there is no way currently to access that so it's a bit hard to do that 
 | 
int | 
execute()  | 
ScriptHelper | 
executeIf(<any> c)  | 
ScriptHelper | 
executeIf(groovy.lang.Closure c)
Deprecated. 
 
since 0.11.0; explicit groovy utilities/support will be deleted. 
 | 
int | 
executeInternal()  | 
ScriptHelper | 
failIfBodyEmpty()  | 
ScriptHelper | 
failOnNonZeroResultCode()  | 
ScriptHelper | 
failOnNonZeroResultCode(boolean val)  | 
ScriptHelper | 
failOnNonZeroResultCodeWithoutUpdatingTask()  | 
ScriptHelper | 
gatherOutput()  | 
ScriptHelper | 
gatherOutput(boolean gather)  | 
java.util.Map | 
getFlags()  | 
java.util.List<java.lang.String> | 
getLines()  | 
java.lang.String | 
getResultStderr()  | 
java.lang.String | 
getResultStdout()  | 
ScriptHelper | 
inessential()  | 
Task<java.lang.Integer> | 
newTask()
creates a task which will execute this script; note this can only be run once per instance of this class 
 | 
ScriptHelper | 
noExtraOutput()
Indicate that no extra output should be appended to stdout. 
 | 
Task<java.lang.Integer> | 
peekTask()
returns the task, if it has been constructed, or null; use  
newTask() to build 
 (if it is null and you need a task) | 
Task<java.lang.Integer> | 
queue()
queues the task for execution if we are in a  
TaskQueueingContext (e.g. | 
ScriptHelper | 
requireResultCode(<any> integerFilter)  | 
ScriptHelper | 
requireResultCode(groovy.lang.Closure integerFilter)
Deprecated. 
 
since 0.11.0; explicit groovy utilities/support will be deleted. 
 | 
<T> ScriptHelper | 
setFlag(ConfigKey<T> flag,
       T value)  | 
ScriptHelper | 
setFlag(java.lang.String flag,
       java.lang.Object value)  | 
void | 
setInessential()  | 
void | 
setTransient()
indicates explicitly that the task can be safely forgotten about after it runs; useful for things like
 check_running which run repeatedly 
 | 
ScriptHelper | 
skipIfBodyEmpty()  | 
ScriptHelper | 
uniqueSshConnection()
Unique ID for the command execution; ensures new SSH connection from the pool. 
 | 
ScriptHelper | 
updateTaskAndFailOnNonZeroResultCode()  | 
ScriptHelper | 
useMutex(WithMutexes mutexSupport,
        java.lang.String mutexId,
        java.lang.String description)
indicates that the script should acquire the given mutexId on the given mutexSupport
 and maintain it for the duration of script execution;
 typically used to prevent parallel scripts from conflicting in access to a resource
 (e.g. 
 | 
public static final org.slf4j.Logger log
public final java.lang.String summary
public final ScriptPart header
public final ScriptPart body
public final ScriptPart footer
public ScriptHelper(NaiveScriptRunner runner, java.lang.String summary)
@Deprecated public ScriptHelper executeIf(groovy.lang.Closure c)
public ScriptHelper executeIf(<any> c)
public ScriptHelper skipIfBodyEmpty()
public ScriptHelper failIfBodyEmpty()
public ScriptHelper failOnNonZeroResultCode(boolean val)
public ScriptHelper failOnNonZeroResultCode()
public ScriptHelper failOnNonZeroResultCodeWithoutUpdatingTask()
public ScriptHelper updateTaskAndFailOnNonZeroResultCode()
@Deprecated public ScriptHelper requireResultCode(groovy.lang.Closure integerFilter)
public ScriptHelper requireResultCode(<any> integerFilter)
public ScriptHelper useMutex(WithMutexes mutexSupport, java.lang.String mutexId, java.lang.String description)
public ScriptHelper gatherOutput()
public ScriptHelper gatherOutput(boolean gather)
public ScriptHelper noExtraOutput()
By default Brooklyn appends a message like "Executed /tmp/brooklyn-20141010-164855950...sh, result 0" to script output.
public ScriptHelper closeSshConnection()
public ScriptHelper uniqueSshConnection()
public void setTransient()
public void setInessential()
public ScriptHelper inessential()
public Task<java.lang.Integer> newTask()
public Task<java.lang.Integer> peekTask()
newTask() to build 
 (if it is null and you need a task)public Task<java.lang.Integer> queue()
TaskQueueingContext (e.g. EffectorTaskFactory); 
 or if we aren't in a queueing context, it will submit the task (assuming there is an ExecutionContext
 _and_ block until completion, throwing on errorpublic int execute()
public int executeInternal()
public java.util.Map getFlags()
public ScriptHelper setFlag(java.lang.String flag, java.lang.Object value)
public <T> ScriptHelper setFlag(ConfigKey<T> flag, T value)
public ScriptHelper environmentVariablesReset()
public ScriptHelper environmentVariablesReset(java.util.Map<?,?> envVarsToSet)
public java.util.List<java.lang.String> getLines()
public java.lang.String getResultStdout()
public java.lang.String getResultStderr()