com.dtolabs.client.services
Class RundeckAPICentralDispatcher

java.lang.Object
  extended by com.dtolabs.client.services.RundeckAPICentralDispatcher
All Implemented Interfaces:
CentralDispatcher

public class RundeckAPICentralDispatcher
extends java.lang.Object
implements CentralDispatcher

RundeckAPICentralDispatcher serializes uses server API v1 to submit requests and receive responses.


Field Summary
static org.apache.log4j.Logger logger
          logger
static java.lang.String RUNDECK_API_BASE
          RUNDECK API base path
static java.lang.String RUNDECK_API_BASE_v4
          RUNDECK API Base for v4
static java.lang.String RUNDECK_API_BASE_v5
          RUNDECK API Base for v5
static java.lang.String RUNDECK_API_BASE_v8
          RUNDECK API Base for v8
static java.lang.String RUNDECK_API_BASE_v9
          RUNDECK API Base for v8
static java.lang.String RUNDECK_API_EXEC_OUTPUT_PATH
          Webservice endpoint for execution output
static java.lang.String RUNDECK_API_EXECUTION_PATH
          Webservice endpoint for getting execution information
static java.lang.String RUNDECK_API_EXECUTION_REPORT
          API endpoint for execution report
static java.lang.String RUNDECK_API_JOBS_BULK_DELETE_PATH
          Webservice endpoint for exporting stored jobs.
static java.lang.String RUNDECK_API_JOBS_EXPORT_PATH
          Webservice endpoint for exporting stored jobs.
static java.lang.String RUNDECK_API_JOBS_LIST_PATH
          Webservice endpoint for listing stored jobs.
static java.lang.String RUNDECK_API_JOBS_RUN
          Webservice endpoint for running job by name or id
static java.lang.String RUNDECK_API_JOBS_UPLOAD
          upload path
static java.lang.String RUNDECK_API_KILL_JOB_PATH
          Webservice endpoint for killing job executions
static java.lang.String RUNDECK_API_LIST_EXECUTIONS_PATH
          Webservice endpoint for queue list requests
static java.lang.String RUNDECK_API_RUN_COMMAND
          Webservice endpoint for running commands
static java.lang.String RUNDECK_API_RUN_SCRIPT
          Webservice endpoint for running scripts
static java.lang.String RUNDECK_API_RUN_URL
          Webservice endpoint for running a script from a URL
static java.lang.String RUNDECK_API_VERSION
          RUNDECK API Version
static java.lang.String RUNDECK_API_VERSION_4
           
static java.lang.String RUNDECK_API_VERSION_5
           
static java.lang.String RUNDECK_API_VERSION_8
           
static java.lang.String RUNDECK_API_VERSION_9
           
static java.lang.String RUNDECK_EXEC_LINK_PREFIX
          Webservice link prefix for an execution
static java.lang.String RUNDECK_JOB_LINK_PREFIX
          Webservice link prefix for a stored job.
 
Fields inherited from interface com.dtolabs.rundeck.core.dispatcher.CentralDispatcher
FORMAT_XML, FORMAT_YAML
 
Constructor Summary
RundeckAPICentralDispatcher(Framework framework)
          Create a RundeckCentralDispatcher
 
Method Summary
static void addAPINodeSetParams(java.util.HashMap<java.lang.String,java.lang.String> params, NodeSet nodeSet, java.lang.Boolean isKeepgoing)
          Add entries to the Map for node filter parameters from the nodeset
 java.util.Collection<DeleteJobResult> deleteStoredJobs(java.util.Collection<java.lang.String> jobIds)
          Delete the jobs specified by the IDs, and return a list of results
 ExecutionFollowResult followDispatcherExecution(java.lang.String execId, ExecutionFollowRequest request, ExecutionFollowReceiver receiver)
          Follow execution output for an Execution by synchronously emitting output to a receiver
 ExecutionDetail getExecution(java.lang.String execId)
          Return execution detail for a particular execution.
 DispatcherResult killDispatcherExecution(java.lang.String execId)
          Attempt to kill the execution of an item currently on the dispatcher queue
 java.util.Collection<QueuedItem> listDispatcherQueue()
          List the items on the dispatcher queue for a project
 java.util.Collection<QueuedItem> listDispatcherQueue(java.lang.String project)
          List the items on the dispatcher queue for a project
 java.util.Collection<IStoredJob> listStoredJobs(IStoredJobsQuery iStoredJobsQuery, java.io.OutputStream output, JobDefinitionFileFormat fformat)
          Return a list of stored jobs matching the query criteria
 java.util.Collection<IStoredJobLoadResult> loadJobs(ILoadJobsRequest iLoadJobsRequest, java.io.File input, JobDefinitionFileFormat format)
          Upload Jobs.xml content to the server
 QueuedItemResult queueDispatcherJob(IDispatchedJob dispatchedJob)
          Add a script dispatch to the dispatcher queue
 QueuedItemResult queueDispatcherScript(IDispatchedScript iDispatchedScript)
          Add a script dispatch to the dispatcher queue
 java.util.Collection<IStoredJob> reallistStoredJobs(IStoredJobsQuery iStoredJobsQuery)
           
 void reportExecutionStatus(java.lang.String project, java.lang.String title, java.lang.String status, int failedNodeCount, int successNodeCount, java.lang.String tags, java.lang.String script, java.lang.String summary, java.util.Date start, java.util.Date end)
          Report execution status
static java.lang.String substitutePathVariable(java.lang.String path, java.lang.String var, java.lang.String value)
          Replace a "$var" within a path string with a value, properly encoding it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RUNDECK_JOB_LINK_PREFIX

public static final java.lang.String RUNDECK_JOB_LINK_PREFIX
Webservice link prefix for a stored job.

See Also:
Constant Field Values

RUNDECK_EXEC_LINK_PREFIX

public static final java.lang.String RUNDECK_EXEC_LINK_PREFIX
Webservice link prefix for an execution

See Also:
Constant Field Values

RUNDECK_API_VERSION

public static final java.lang.String RUNDECK_API_VERSION
RUNDECK API Version

See Also:
Constant Field Values

RUNDECK_API_VERSION_4

public static final java.lang.String RUNDECK_API_VERSION_4
See Also:
Constant Field Values

RUNDECK_API_VERSION_5

public static final java.lang.String RUNDECK_API_VERSION_5
See Also:
Constant Field Values

RUNDECK_API_VERSION_8

public static final java.lang.String RUNDECK_API_VERSION_8
See Also:
Constant Field Values

RUNDECK_API_VERSION_9

public static final java.lang.String RUNDECK_API_VERSION_9
See Also:
Constant Field Values

RUNDECK_API_BASE

public static final java.lang.String RUNDECK_API_BASE
RUNDECK API base path

See Also:
Constant Field Values

RUNDECK_API_BASE_v4

public static final java.lang.String RUNDECK_API_BASE_v4
RUNDECK API Base for v4

See Also:
Constant Field Values

RUNDECK_API_BASE_v5

public static final java.lang.String RUNDECK_API_BASE_v5
RUNDECK API Base for v5

See Also:
Constant Field Values

RUNDECK_API_BASE_v8

public static final java.lang.String RUNDECK_API_BASE_v8
RUNDECK API Base for v8

See Also:
Constant Field Values

RUNDECK_API_BASE_v9

public static final java.lang.String RUNDECK_API_BASE_v9
RUNDECK API Base for v8

See Also:
Constant Field Values

RUNDECK_API_EXECUTION_REPORT

public static final java.lang.String RUNDECK_API_EXECUTION_REPORT
API endpoint for execution report

See Also:
Constant Field Values

RUNDECK_API_RUN_SCRIPT

public static final java.lang.String RUNDECK_API_RUN_SCRIPT
Webservice endpoint for running scripts

See Also:
Constant Field Values

RUNDECK_API_RUN_COMMAND

public static final java.lang.String RUNDECK_API_RUN_COMMAND
Webservice endpoint for running commands

See Also:
Constant Field Values

RUNDECK_API_RUN_URL

public static final java.lang.String RUNDECK_API_RUN_URL
Webservice endpoint for running a script from a URL

See Also:
Constant Field Values

RUNDECK_API_LIST_EXECUTIONS_PATH

public static final java.lang.String RUNDECK_API_LIST_EXECUTIONS_PATH
Webservice endpoint for queue list requests

See Also:
Constant Field Values

RUNDECK_API_EXECUTION_PATH

public static final java.lang.String RUNDECK_API_EXECUTION_PATH
Webservice endpoint for getting execution information

See Also:
Constant Field Values

RUNDECK_API_KILL_JOB_PATH

public static final java.lang.String RUNDECK_API_KILL_JOB_PATH
Webservice endpoint for killing job executions

See Also:
Constant Field Values

RUNDECK_API_EXEC_OUTPUT_PATH

public static final java.lang.String RUNDECK_API_EXEC_OUTPUT_PATH
Webservice endpoint for execution output

See Also:
Constant Field Values

RUNDECK_API_JOBS_EXPORT_PATH

public static final java.lang.String RUNDECK_API_JOBS_EXPORT_PATH
Webservice endpoint for exporting stored jobs.

See Also:
Constant Field Values

RUNDECK_API_JOBS_BULK_DELETE_PATH

public static final java.lang.String RUNDECK_API_JOBS_BULK_DELETE_PATH
Webservice endpoint for exporting stored jobs.

See Also:
Constant Field Values

RUNDECK_API_JOBS_LIST_PATH

public static final java.lang.String RUNDECK_API_JOBS_LIST_PATH
Webservice endpoint for listing stored jobs.

See Also:
Constant Field Values

RUNDECK_API_JOBS_UPLOAD

public static final java.lang.String RUNDECK_API_JOBS_UPLOAD
upload path

See Also:
Constant Field Values

RUNDECK_API_JOBS_RUN

public static final java.lang.String RUNDECK_API_JOBS_RUN
Webservice endpoint for running job by name or id

See Also:
Constant Field Values

logger

public static final org.apache.log4j.Logger logger
logger

Constructor Detail

RundeckAPICentralDispatcher

public RundeckAPICentralDispatcher(Framework framework)
Create a RundeckCentralDispatcher

Parameters:
framework - the framework
Method Detail

reportExecutionStatus

public void reportExecutionStatus(java.lang.String project,
                                  java.lang.String title,
                                  java.lang.String status,
                                  int failedNodeCount,
                                  int successNodeCount,
                                  java.lang.String tags,
                                  java.lang.String script,
                                  java.lang.String summary,
                                  java.util.Date start,
                                  java.util.Date end)
                           throws CentralDispatcherException
Report execution status

Specified by:
reportExecutionStatus in interface CentralDispatcher
Parameters:
project - project
title - execution title
status - result status, either 'succeed','cancel','fail'
failedNodeCount - total node count
successNodeCount - count of successful nodes
tags -
script - script content (can be null if summary specified)
summary - summary of execution (can be null if script specified)
start - start date (can be null)
end - end date (can be null)
Throws:
CentralDispatcherException

queueDispatcherScript

public QueuedItemResult queueDispatcherScript(IDispatchedScript iDispatchedScript)
                                       throws CentralDispatcherException
Description copied from interface: CentralDispatcher
Add a script dispatch to the dispatcher queue

Specified by:
queueDispatcherScript in interface CentralDispatcher
Parameters:
iDispatchedScript - script dispatch descriptor
Returns:
QueuedItemResult indicating success/failure of queue request.
Throws:
CentralDispatcherException - if an error occurs

listDispatcherQueue

public java.util.Collection<QueuedItem> listDispatcherQueue()
                                                     throws CentralDispatcherException
List the items on the dispatcher queue for a project

Specified by:
listDispatcherQueue in interface CentralDispatcher
Returns:
Collection of Strings listing the active dispatcher queue items
Throws:
CentralDispatcherException - if an error occurs

listDispatcherQueue

public java.util.Collection<QueuedItem> listDispatcherQueue(java.lang.String project)
                                                     throws CentralDispatcherException
List the items on the dispatcher queue for a project

Specified by:
listDispatcherQueue in interface CentralDispatcher
Parameters:
project - Project name
Returns:
Collection of Strings listing the active dispatcher queue items
Throws:
CentralDispatcherException - if an error occurs

killDispatcherExecution

public DispatcherResult killDispatcherExecution(java.lang.String execId)
                                         throws CentralDispatcherException
Description copied from interface: CentralDispatcher
Attempt to kill the execution of an item currently on the dispatcher queue

Specified by:
killDispatcherExecution in interface CentralDispatcher
Parameters:
execId - the ID string of the item
Returns:
result, success if the item was running and was successfully killed, false if the item could not be killed or the item was not running
Throws:
CentralDispatcherException - if an error occurs

getExecution

public ExecutionDetail getExecution(java.lang.String execId)
                             throws CentralDispatcherException
Return execution detail for a particular execution.

Specified by:
getExecution in interface CentralDispatcher
Parameters:
execId - ID of the execution
Returns:
Execution detail
Throws:
CentralDispatcherException

followDispatcherExecution

public ExecutionFollowResult followDispatcherExecution(java.lang.String execId,
                                                       ExecutionFollowRequest request,
                                                       ExecutionFollowReceiver receiver)
                                                throws CentralDispatcherException
Follow execution output for an Execution by synchronously emitting output to a receiver

Specified by:
followDispatcherExecution in interface CentralDispatcher
Parameters:
execId -
Returns:
result, success if the item was running and was successfully killed, false if the item could not be killed or the item was not running
Throws:
CentralDispatcherException - if an error occurs

substitutePathVariable

public static java.lang.String substitutePathVariable(java.lang.String path,
                                                      java.lang.String var,
                                                      java.lang.String value)
                                               throws CentralDispatcherException
Replace a "$var" within a path string with a value, properly encoding it.

Parameters:
path - the URL path to substitute the var within
var - the name of the var in the string
value - the value to substitute
Throws:
CentralDispatcherException

listStoredJobs

public java.util.Collection<IStoredJob> listStoredJobs(IStoredJobsQuery iStoredJobsQuery,
                                                       java.io.OutputStream output,
                                                       JobDefinitionFileFormat fformat)
                                                throws CentralDispatcherException
Description copied from interface: CentralDispatcher
Return a list of stored jobs matching the query criteria

Specified by:
listStoredJobs in interface CentralDispatcher
Parameters:
iStoredJobsQuery - jobs query
output - optional outputstream to store the XML content
Returns:
collection of IStoredJob objects matching the query.
Throws:
CentralDispatcherException - if an error occurs

deleteStoredJobs

public java.util.Collection<DeleteJobResult> deleteStoredJobs(java.util.Collection<java.lang.String> jobIds)
                                                       throws CentralDispatcherException
Description copied from interface: CentralDispatcher
Delete the jobs specified by the IDs, and return a list of results

Specified by:
deleteStoredJobs in interface CentralDispatcher
Parameters:
jobIds - the job IDs
Returns:
collection of DeleteJobResults
Throws:
CentralDispatcherException - if an error occurs

reallistStoredJobs

public java.util.Collection<IStoredJob> reallistStoredJobs(IStoredJobsQuery iStoredJobsQuery)
                                                    throws CentralDispatcherException
Throws:
CentralDispatcherException

queueDispatcherJob

public QueuedItemResult queueDispatcherJob(IDispatchedJob dispatchedJob)
                                    throws CentralDispatcherException
Description copied from interface: CentralDispatcher
Add a script dispatch to the dispatcher queue

Specified by:
queueDispatcherJob in interface CentralDispatcher
Parameters:
dispatchedJob - job execution reference definition
Returns:
QueuedItemResult indicating success/failure of queue request.
Throws:
CentralDispatcherException - if an error occurs

addAPINodeSetParams

public static void addAPINodeSetParams(java.util.HashMap<java.lang.String,java.lang.String> params,
                                       NodeSet nodeSet,
                                       java.lang.Boolean isKeepgoing)
Add entries to the Map for node filter parameters from the nodeset


loadJobs

public java.util.Collection<IStoredJobLoadResult> loadJobs(ILoadJobsRequest iLoadJobsRequest,
                                                           java.io.File input,
                                                           JobDefinitionFileFormat format)
                                                    throws CentralDispatcherException
Description copied from interface: CentralDispatcher
Upload Jobs.xml content to the server

Specified by:
loadJobs in interface CentralDispatcher
Parameters:
iLoadJobsRequest - load request parameters
input - XML file
Returns:
collection of IStoredJobLoadResult objects, indicating the status of each job in the input file.
Throws:
CentralDispatcherException - if an error occurs