DIVINE CLOUD SDK


DivineCloud provides a Java SDK that can be used by any java application directly. SDK can be used to execute one or more command or script or run-books.

Following is a simple example of using DivineCloud SDK for executing command:

CmdApi api = ApiBuilder.buildCmdApi(batchSize); // Thread batch size
List<NodeExecutionDetails> result = api.execute(list, cmd);
                                        

Above example is a blocking api call. The api.execute() method is blocked until the execution is complete. There is also a non-blocking api support available as shown below:

CmdApi api = ApiBuilder.buildCmdApi(batchSize); // Thread batch size
String execId = api.execute(list, cmd, groupTermCallback);
                                        

Following is a simple example of using DivineCloud SDK for executing RunBook:

RunBookApi api = ApiBuilder.buildRunBookApi(batchSize);  // Thread batch size
api.execute(nodesPerStep, runBook, callback, properties);
                                        

In the above example, the output of the run-book execution is streamed to the callback class, alternatively, there is an api to write the output to a text file instead of streaming it to the callback class, as shown below:

RunBookApi api = ApiBuilder.buildRunBookApi(batchSize);  // Thread batch size
api.execute(File nodesPerStepFile, File runbook, File outputFile, File credentialsProviderFile, File propertiesFile, boolean emitOutput);
                                        

 

The complete source code is available on Github along with unit test examples to demonstrate the SDK usage. The SDK unit tests for command & run-book executions are available at https://github.com/divinecloud/DivineCloud/tree/master/dc-java-api/src/test