Java Code Examples for org.jclouds.compute.ComputeService#runScriptOnNodesMatching()
The following examples show how to use
org.jclouds.compute.ComputeService#runScriptOnNodesMatching() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainApp.java From jclouds-examples with Apache License 2.0 | 6 votes |
private static void runScriptOnGroup(final ComputeService compute, final LoginCredentials login, final String groupName, final Statement command) throws RunScriptOnNodesException { // when you run commands, you can pass options to decide whether // to run it as root, supply or own credentials vs from cache, // and wrap in an init script vs directly invoke Map<? extends NodeMetadata, ExecResponse> execResponses = compute.runScriptOnNodesMatching(// inGroup(groupName), // predicate used to select nodes command, // what you actually intend to run overrideLoginCredentials(login)); // use the local user & ssh key for (Entry<? extends NodeMetadata, ExecResponse> response : execResponses.entrySet()) { System.out.printf( "<< node %s: %s%n", response.getKey().getId(), concat(response.getKey().getPrivateAddresses(), response.getKey() .getPublicAddresses()) ); System.out.printf("<< %s%n", response.getValue()); } }