public abstract boolean runAsRoot();
@Override
protected Object doExecute() throws Exception {
ComputeService service = null;
try {
service = getComputeService();
} catch (Throwable t) {
System.err.println(t.getMessage());
return null;
}
Set<? extends NodeMetadata> nodeMetaDataSet = service.listNodesDetailsMatching(getComputeFilter());
if (nodeMetaDataSet != null && !nodeMetaDataSet.isEmpty()) {
NodeMetadata nodeMetadata = nodeMetaDataSet.toArray(new NodeMetadata[0])[0];
// If we have multiple nodes we just want the headers, but not full details.
printNodeInfo(service, nodeMetaDataSet, nodeMetaDataSet.size() == 1, System.out);
LoginCredentials credentials = nodeMetadata.getCredentials();
user = EnvHelper.getUser(user);
password = EnvHelper.getPassword(password);
if (user != null) {
LoginCredentials.Builder loginBuilder;
if (credentials == null) {
loginBuilder = LoginCredentials.builder();
} else {
loginBuilder = credentials.toBuilder();
}
if (password != null) {
credentials = loginBuilder.user(user).password(password).build();
} else {
credentials = loginBuilder.user(user).build();
}
}
Map<? extends NodeMetadata, ExecResponse> responseMap = null;
if (getScript() != null) {
responseMap = service.runScriptOnNodesMatching(getNodeFilter(),
getScript(), overrideLoginCredentials(credentials).runAsRoot(runAsRoot()));
} else if (getStatement() != null) {
responseMap = service.runScriptOnNodesMatching(getNodeFilter(),
getStatement(), overrideLoginCredentials(credentials).runAsRoot(runAsRoot()));
}
for (Map.Entry<? extends NodeMetadata, ExecResponse> entry : responseMap.entrySet()) {
ExecResponse response = entry.getValue();