org.jclouds.compute.RunScriptOnNodesException Java Examples

The following examples show how to use org.jclouds.compute.RunScriptOnNodesException. 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 vote down vote up
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());
    }
}
 
Example #2
Source File: OpenStackConnector.java    From cloudml with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Execute a command on a group of VMs
 * @param group name of the group
 * @param command the command to be executed
 * @param login username
 * @param key sshkey
 * @throws RunScriptOnNodesException
 */
public void execCommandInGroup(String group, String command, String login, String key) throws RunScriptOnNodesException {
    journal.log(Level.INFO, ">> executing command...");
    journal.log(Level.INFO, ">> "+ command);

    org.jclouds.domain.LoginCredentials.Builder b=initCredentials(login, key);
    Map<? extends NodeMetadata, ExecResponse> responses = novaComputeService.runScriptOnNodesMatching(
            runningInGroup(group),
            exec(command),
            overrideLoginCredentials(b.build())
                    .runAsRoot(false)
                    .wrapInInitScript(false));// run command directly

    for(Map.Entry<? extends NodeMetadata, ExecResponse> r : responses.entrySet())
        journal.log(Level.INFO, ">> "+r.getValue());
}
 
Example #3
Source File: JCloudsConnector.java    From cloudml with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Execute a command on a group of vms
 * @param group name of the group
 * @param command the command to be executed
 * @param login username
 * @param key sshkey
 * @throws RunScriptOnNodesException
 */
public void execCommandInGroup(String group, String command, String login, String key) throws RunScriptOnNodesException{
    journal.log(Level.INFO, ">> executing command...");
    journal.log(Level.INFO, ">> "+ command);

    org.jclouds.domain.LoginCredentials.Builder b=initCredentials(login, key);
    journal.log(Level.INFO, ">> executing command..."+b.build());
    Map<? extends NodeMetadata, ExecResponse> responses = compute.runScriptOnNodesMatching(
            runningInGroup(group),
            exec(command),
            overrideLoginCredentials(b.build())
                    .runAsRoot(false)
                    .wrapInInitScript(false));// run command directly

    for(Entry<? extends NodeMetadata, ExecResponse> r : responses.entrySet())
        journal.log(Level.INFO, ">> "+r.getValue());
}
 
Example #4
Source File: DelegatingComputeService.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<? super NodeMetadata> filter, String runScript) throws RunScriptOnNodesException {
    return delegate.runScriptOnNodesMatching(filter, runScript);
}
 
Example #5
Source File: DelegatingComputeService.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<? super NodeMetadata> filter, Statement runScript) throws RunScriptOnNodesException {
    return delegate.runScriptOnNodesMatching(filter, runScript);
}
 
Example #6
Source File: DelegatingComputeService.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<? super NodeMetadata> filter, String runScript, RunScriptOptions options) throws RunScriptOnNodesException {
    return delegate.runScriptOnNodesMatching(filter, runScript, options);
}
 
Example #7
Source File: DelegatingComputeService.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<? super NodeMetadata> filter, Statement runScript, RunScriptOptions options) throws RunScriptOnNodesException {
    return delegate.runScriptOnNodesMatching(filter, runScript, options);
}
 
Example #8
Source File: UnsupportedComputeService.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<? super NodeMetadata> filter, String runScript) throws RunScriptOnNodesException {
    throw new UnsupportedOperationException();
}
 
Example #9
Source File: UnsupportedComputeService.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<? super NodeMetadata> filter, Statement runScript) throws RunScriptOnNodesException {
    throw new UnsupportedOperationException();
}
 
Example #10
Source File: UnsupportedComputeService.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<? super NodeMetadata> filter, String runScript, RunScriptOptions options) throws RunScriptOnNodesException {
    throw new UnsupportedOperationException();
}
 
Example #11
Source File: UnsupportedComputeService.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<? super NodeMetadata> filter, Statement runScript, RunScriptOptions options) throws RunScriptOnNodesException {
    throw new UnsupportedOperationException();
}