Skip to content

Commit 1190d76

Browse files
committed
CLOUDSTACK-9470: Fix for SshHelper - test_network_acl was failing on Vmware due to a bug in sshExecute, in which value returned was null and there was still stdout to consume. This fix addresses this problem, consuming stdout peoperly to return expected value in sshExecute
1 parent 0671a80 commit 1190d76

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

utils/src/main/java/com/cloud/utils/ssh/SshHelper.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
import java.io.File;
2323
import java.io.IOException;
2424
import java.io.InputStream;
25+
import java.nio.charset.StandardCharsets;
26+
27+
import org.apache.commons.io.IOUtils;
28+
import org.apache.commons.lang.StringUtils;
2529

2630
import org.apache.log4j.Logger;
2731

@@ -196,6 +200,16 @@ public static Pair<Boolean, String> sshExecute(String host, int port, String use
196200

197201
String result = sbResult.toString();
198202

203+
if (StringUtils.isBlank(result)) {
204+
try {
205+
result = IOUtils.toString(stdout, StandardCharsets.UTF_8);
206+
}
207+
catch (IOException e) {
208+
s_logger.error("Couldn't get content of input stream due to: " + e.getMessage());
209+
return new Pair<Boolean, String>(false, result);
210+
}
211+
}
212+
199213
if (sess.getExitStatus() == null) {
200214
//Exit status is NOT available. Returning failure result.
201215
s_logger.error(String.format("SSH execution of command %s has no exit status set. Result output: %s", command, result));

0 commit comments

Comments
 (0)