LoginCredentials credentials = null;
if (user != null) {
credentials = LoginCredentials.builder().user(user).build();
}
ExecResponse execResponse = null;
if (credentials == null) {
execResponse = computeService.runScriptOnNode(nodeId, script);
} else {
execResponse = computeService.runScriptOnNode(nodeId, script, RunScriptOptions.Builder.overrideLoginCredentials(credentials).runAsRoot(false));
}
if (execResponse == null) {
throw new CamelException("Failed to receive response for run script operation.");
}
exchange.setProperty(JcloudsConstants.RUN_SCRIPT_ERROR, execResponse.getError());
exchange.setProperty(JcloudsConstants.RUN_SCRIPT_EXIT_CODE, execResponse.getExitCode());
exchange.getOut().setBody(execResponse.getOutput());
}