|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.dtolabs.rundeck.core.cli.ExecTool
public class ExecTool
Main class for dispatch
command line tool. This command will dispatch the command either locally or
remotely.
Nested Class Summary | |
---|---|
static interface |
ExecTool.NodeFormatter
|
Field Summary | |
---|---|
protected org.apache.commons.cli.CommandLine |
cli
Reference to command line params |
static java.lang.String |
DEFAULT_LOG_FORMAT
|
protected java.io.PrintStream |
err
|
protected ExecTool.NodeFormatter |
nodeFormatter
|
static int |
NODESET_EMPTY_EXIT_CODE
Exit code for a Nodeset Empty failure exception |
protected static org.apache.commons.cli.Options |
options
reference to the command line Options instance. |
protected java.io.PrintStream |
out
|
Constructor Summary | |
---|---|
ExecTool(Framework framework)
Create a new ExecTool with the given framework instance. |
Method Summary | |
---|---|
protected void |
configurePrintStream(boolean quiet)
Reconfigures the System.out PrintStream to write to a file output stream. |
protected NodeSet |
createFilterNodeSelector()
Crete a NodeSet using the parsed argument values |
protected NodeSet |
createNodeSet(java.util.Map includeMap,
java.util.Map excludeMap)
Create a NodeSet using the included maps, where exclusion has precedence |
protected static NodeSet |
createNodeSet(java.util.Map includeMap,
java.util.Map excludeMap,
boolean excludePrecedence,
java.lang.Integer threadCount,
boolean keepgoing,
java.io.File failedNodesfile)
Create a NodeSet using the included maps, and boolean exclude value |
void |
debug(java.lang.String message)
Logs debug message via implementation specific log facility |
void |
debug(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context)
|
void |
error(java.lang.String message)
Logs error message via implementation specific log facility |
void |
error(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context)
|
void |
exit(int exitcode)
Calls the exit method |
java.lang.String |
generateExecLine(java.util.Map<java.lang.String,java.lang.String> filterArgs)
Generates the commandline execution string used. |
int |
getAntLoglevel()
Return the Ant loglevel equivalent to the input flags (verbose,debug,quiet). |
java.lang.String |
getArgFrameworkProject()
|
java.lang.String[] |
getArgs()
Get the argument line definition |
java.lang.String[] |
getArgsDeferred()
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getDataContext()
Return data context set |
Framework |
getFramework()
|
java.lang.String |
getFrameworkProject()
Get the framework project name |
java.lang.String |
getInlineScriptContent()
|
int |
getLoglevel()
Return the loglevel value, using the Ant equivalents: DEBUG=1, |
java.lang.Boolean |
getNodeExcludePrecedence()
boolean value specifying that exclusion node filters have precedence over inclusion filters |
java.lang.String |
getNodeFilter()
|
java.lang.String |
getNodeRankAttribute()
|
INodeSet |
getNodes()
|
NodesSelector |
getNodeSelector()
|
NodeSet |
getNodeSet()
|
int |
getNodeThreadcount()
Return the node dispatch threadcount |
java.lang.String |
getScript()
Get the full script |
java.io.InputStream |
getScriptAsStream()
Get an InputStream that can provide the full script |
java.lang.String |
getScriptpath()
|
java.lang.String |
getScriptURLString()
Get the script URL |
java.lang.String |
getServerScriptFilePath()
Get the server-local script path |
int |
getThreadCount()
|
void |
help()
Writes help message to implementation specific output channel. |
boolean |
isDebug()
Return true if debug logging is on |
boolean |
isInlineScript()
|
java.lang.Boolean |
isKeepgoing()
Return true or false for node dispatch keepgoing option, or null if unspecified. |
boolean |
isNodeRankOrderAscending()
|
boolean |
isQuiet()
Return true if quiet logging is on |
boolean |
isVerbose()
Return true for verbose logging |
void |
log(java.lang.String message)
Logs message via implementation specific log facility |
void |
log(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context)
|
static void |
main(java.lang.String[] args)
Creates an instance and executes run(String[]) . |
org.apache.commons.cli.CommandLine |
parseArgs(java.lang.String[] args)
Reads the argument vector and constructs a CommandLine object containing params |
protected java.util.Map |
parseExcludeArgs(java.lang.String[] keys)
Parse the value of the -X option |
protected static java.util.Map<java.lang.String,java.lang.String> |
parseFilterArgs(java.lang.String[] keys,
org.apache.commons.cli.CommandLine cli,
java.lang.String opt)
|
protected java.util.Map |
parseIncludeArgs(java.lang.String[] keys)
Parse the value of the -X option. |
protected static java.util.Map<java.lang.String,java.lang.String> |
parseMultiNodeArgs(java.lang.String[] keys,
java.lang.String[] values)
Parse the values as key=value pairs, using the set of allowed keys. |
void |
run(java.lang.String[] args)
The run method carries out the lifecycle of the tool, parsing args, handling exceptions, and exiting with a suitable exit code. |
void |
setNodeExcludePrecedence(boolean nodeExcludePrecedence)
|
void |
setNodeFilter(java.lang.String nodeFilter)
|
void |
setNodeThreadcount(java.lang.Integer nodeThreadcount)
|
void |
setScriptAsStream(java.io.InputStream scriptAsStream)
|
void |
verbose(java.lang.String message)
Logs verbose message via implementation specific log facility |
void |
verbose(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context)
|
void |
warn(java.lang.String message)
Logs warning message via implementation specific log facility |
void |
warn(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context)
|
protected java.io.File |
writeInputToFile(java.io.InputStream input)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.PrintStream err
protected java.io.PrintStream out
protected org.apache.commons.cli.CommandLine cli
protected static final org.apache.commons.cli.Options options
Options
instance.
protected ExecTool.NodeFormatter nodeFormatter
public static final int NODESET_EMPTY_EXIT_CODE
public static final java.lang.String DEFAULT_LOG_FORMAT
Constructor Detail |
---|
public ExecTool(Framework framework)
framework
- framework instanceMethod Detail |
---|
public org.apache.commons.cli.CommandLine parseArgs(java.lang.String[] args)
CommandLine
object containing params
parseArgs
in interface CLITool
args
- the cli arg vector
public java.lang.String generateExecLine(java.util.Map<java.lang.String,java.lang.String> filterArgs)
filterArgs
- set of filter commandline arguments to insert
protected java.util.Map parseExcludeArgs(java.lang.String[] keys)
keys
-
protected java.util.Map parseIncludeArgs(java.lang.String[] keys)
keys
-
public void run(java.lang.String[] args)
run
in interface CLITool
args
- the cli arg vectorprotected NodeSet createFilterNodeSelector()
protected NodeSet createNodeSet(java.util.Map includeMap, java.util.Map excludeMap)
includeMap
- include mapexcludeMap
- exclude map
protected static NodeSet createNodeSet(java.util.Map includeMap, java.util.Map excludeMap, boolean excludePrecedence, java.lang.Integer threadCount, boolean keepgoing, java.io.File failedNodesfile)
includeMap
- include mapexcludeMap
- exclude mapexcludePrecedence
- if true, exclusion has precedencethreadCount
- the threadcountkeepgoing
- keepgoing booleanfailedNodesfile
- file indicating list of failed nodes
public static void main(java.lang.String[] args) throws java.lang.Exception
run(String[])
.
args
-
java.lang.Exception
public void exit(int exitcode)
exit
in interface CLITool
exitcode
- return code to exit withpublic void help()
help
in interface CLITool
public void log(java.lang.String message)
log
in interface BaseLogger
message
- message to logpublic void warn(java.lang.String message)
warn
in interface BaseLogger
message
- message to logpublic void error(java.lang.String message)
error
in interface BaseLogger
message
- message to logpublic void debug(java.lang.String message)
BaseLogger
debug
in interface BaseLogger
message
- message to logpublic void verbose(java.lang.String message)
verbose
in interface BaseLogger
message
- message to logprotected void configurePrintStream(boolean quiet)
quiet
- If true, configures to write to a file.public java.lang.String getArgFrameworkProject()
public java.lang.String[] getArgsDeferred()
public java.lang.String getScriptpath()
public boolean isInlineScript()
public java.lang.String getInlineScriptContent()
public Framework getFramework()
public NodesSelector getNodeSelector()
public INodeSet getNodes()
public int getThreadCount()
public java.lang.String getNodeRankAttribute()
public boolean isNodeRankOrderAscending()
public java.lang.Boolean isKeepgoing()
IDispatchedExecution
isKeepgoing
in interface IDispatchedExecution
public java.lang.String getFrameworkProject()
IDispatchedScript
getFrameworkProject
in interface IDispatchedScript
public java.lang.String getScript()
IDispatchedScript
getScript
in interface IDispatchedScript
public java.io.InputStream getScriptAsStream()
IDispatchedScript
getScriptAsStream
in interface IDispatchedScript
public void setScriptAsStream(java.io.InputStream scriptAsStream)
public java.lang.String getServerScriptFilePath()
IDispatchedScript
getServerScriptFilePath
in interface IDispatchedScript
public NodeSet getNodeSet()
public java.lang.String[] getArgs()
IDispatchedExecution
getArgs
in interface IDispatchedExecution
public int getLoglevel()
IDispatchedExecution
getLoglevel
in interface IDispatchedExecution
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getDataContext()
IDispatchedExecution
getDataContext
in interface IDispatchedExecution
protected static java.util.Map<java.lang.String,java.lang.String> parseMultiNodeArgs(java.lang.String[] keys, java.lang.String[] values)
keys
- allowed keys for the key=value strings, the first key is used as the default keyvalues
- array of key=value strings, or merely 1 value string if the array is size 1
protected static java.util.Map<java.lang.String,java.lang.String> parseFilterArgs(java.lang.String[] keys, org.apache.commons.cli.CommandLine cli, java.lang.String opt)
public java.lang.String getScriptURLString()
IDispatchedScript
getScriptURLString
in interface IDispatchedScript
public java.lang.String getNodeFilter()
getNodeFilter
in interface IDispatchedExecution
public void setNodeFilter(java.lang.String nodeFilter)
public java.lang.Boolean getNodeExcludePrecedence()
getNodeExcludePrecedence
in interface IDispatchedExecution
public void setNodeExcludePrecedence(boolean nodeExcludePrecedence)
public int getNodeThreadcount()
IDispatchedExecution
getNodeThreadcount
in interface IDispatchedExecution
public void setNodeThreadcount(java.lang.Integer nodeThreadcount)
protected java.io.File writeInputToFile(java.io.InputStream input)
public int getAntLoglevel()
public boolean isDebug()
CLILoggerParams
isDebug
in interface CLILoggerParams
public boolean isVerbose()
CLILoggerParams
isVerbose
in interface CLILoggerParams
public boolean isQuiet()
CLILoggerParams
isQuiet
in interface CLILoggerParams
public void log(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
public void error(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
public void warn(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
public void verbose(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
public void debug(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |