Github user bostko commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/866#discussion_r38088447
--- Diff:
software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessWinRmDriver.java
---
@@ -119,20 +136,53 @@ protected void createDirectory(String directoryName,
String summaryForLogging) {
protected WinRmToolResponse executeCommand(ConfigKey<String>
regularCommandKey, ConfigKey<String> powershellCommandKey, boolean allowNoOp) {
String regularCommand = getEntity().getConfig(regularCommandKey);
String powershellCommand =
getEntity().getConfig(powershellCommandKey);
- if (Strings.isNullOrEmpty(regularCommand) &&
Strings.isNullOrEmpty(powershellCommand)) {
+ if (Strings.isBlank(regularCommand) &&
Strings.isBlank(powershellCommand)) {
if (allowNoOp) {
return new WinRmToolResponse("", "", 0);
} else {
throw new IllegalStateException(String.format("Exactly one
of %s or %s must be set", regularCommandKey.getName(),
powershellCommandKey.getName()));
}
- } else if (!Strings.isNullOrEmpty(regularCommand) &&
!Strings.isNullOrEmpty(powershellCommand)) {
+ } else if (!Strings.isBlank(regularCommand) &&
!Strings.isBlank(powershellCommand)) {
throw new IllegalStateException(String.format("%s and %s
cannot both be set", regularCommandKey.getName(),
powershellCommandKey.getName()));
}
- if (Strings.isNullOrEmpty(regularCommand)) {
- return
getLocation().executePsScript(ImmutableList.of(powershellCommand));
+ ByteArrayOutputStream stdIn = new ByteArrayOutputStream();
+ ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
+ ByteArrayOutputStream stdErr = new ByteArrayOutputStream();
+
+ boolean tagWithStd = Tasks.current() != null;
+ if (tagWithStd) {
+ writeToStream(stdIn, Strings.isBlank(regularCommand) ?
powershellCommand : regularCommand);
+
Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDIN,
stdIn));
+
+ if (BrooklynTaskTags.stream(Tasks.current(),
BrooklynTaskTags.STREAM_STDOUT)==null) {
+
Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDOUT,
stdOut));
+
Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDERR,
stdErr));
+ }
+ }
+
+ WinRmToolResponse response;
+ if (Strings.isBlank(regularCommand)) {
+ response =
getLocation().executePsScript(ImmutableList.of(powershellCommand));
} else {
- return
getLocation().executeScript(ImmutableList.of(regularCommand));
+ response =
getLocation().executeScript(ImmutableList.of(regularCommand));
+ }
+
+ if (tagWithStd) {
+ if (BrooklynTaskTags.stream(Tasks.current(),
BrooklynTaskTags.STREAM_STDOUT)==null) {
--- End diff --
I've followed the pattern from here
https://github.com/apache/incubator-brooklyn/blob/master/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java#L262
There it is used check for STDOUT availability
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---