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
|
ScriptHelper |
environmentVariablesReset(java.util.Map<?,?> envVarsToSet)
overrides the default environment variables to use the given set; by default they will be inherited.
|
int |
execute() |
ScriptHelper |
executeIf(groovy.lang.Closure c)
Takes a closure which accepts this ScriptHelper and returns true or false
as to whether the script needs to run (or can throw error if desired)
|
ScriptHelper |
executeIf(com.google.common.base.Predicate<? super ScriptHelper> c) |
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(groovy.lang.Closure integerFilter)
Convenience for error-checking the result.
|
ScriptHelper |
requireResultCode(com.google.common.base.Predicate<? super java.lang.Integer> integerFilter) |
<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)
public ScriptHelper executeIf(groovy.lang.Closure c)
public ScriptHelper executeIf(com.google.common.base.Predicate<? super ScriptHelper> c)
public ScriptHelper skipIfBodyEmpty()
public ScriptHelper failIfBodyEmpty()
public ScriptHelper failOnNonZeroResultCode(boolean val)
public ScriptHelper failOnNonZeroResultCode()
public ScriptHelper failOnNonZeroResultCodeWithoutUpdatingTask()
public ScriptHelper updateTaskAndFailOnNonZeroResultCode()
public ScriptHelper requireResultCode(groovy.lang.Closure integerFilter)
public ScriptHelper requireResultCode(com.google.common.base.Predicate<? super java.lang.Integer> 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)@Beta 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()