brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Capture exit code in AbstractSoft...
Date Fri, 18 Sep 2015 09:33:37 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/906#discussion_r39838423
  
    --- Diff: software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessWinRmDriver.java
---
    @@ -134,18 +189,23 @@ protected void createDirectory(String directoryName, String summaryForLogging)
{
             getLocation().executePsScript("New-Item -path \"" + directoryName + "\" -type
directory -ErrorAction SilentlyContinue");
         }
     
    -    protected WinRmToolResponse executeCommand(ConfigKey<String> regularCommandKey,
ConfigKey<String> powershellCommandKey, boolean allowNoOp) {
    -        String regularCommand = getEntity().getConfig(regularCommandKey);
    -        String powershellCommand = getEntity().getConfig(powershellCommandKey);
    +    public int executeCommand(String regularCommand, String powershellCommand, String
phase, Boolean allowNoOp) {
    +        return executeCommand(MutableMap.of(), regularCommand, powershellCommand, phase,
allowNoOp);
    +    }
    +
    +    @Override
    +    public Integer executeCommand(Map flags2, String regularCommand, String powershellCommand,
String phase, Boolean allowNoOp) {
             if (Strings.isBlank(regularCommand) && Strings.isBlank(powershellCommand))
{
                 if (allowNoOp) {
    -                return new WinRmToolResponse("", "", 0);
    +                return new WinRmToolResponse("", "", 0).getStatusCode();
                 } else {
    -                throw new IllegalStateException(String.format("Exactly one of %s or %s
must be set", regularCommandKey.getName(), powershellCommandKey.getName()));
    +                throw new IllegalStateException(String.format("Exactly one of %s or %s
must be set", regularCommand, 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()));
    +            throw new IllegalStateException(String.format("%s and %s cannot both be set",
regularCommand, powershellCommand));
             }
    +        Map flags = Maps.newLinkedHashMap();
    --- End diff --
    
    I don't understand how you are using `flags` and `flags2`. You put things into `flags2`,
but it looks like the map is never used?
    
    Now that you don't return `WinRmToolResponse`, we need another way for someone to get
the stdout/stderr. The way ssh does it is to allow someone to pass in an `OutputStream` in
the `flags2` parameter, using the keys `out` and `err`. If they are passed in, then they are
populated with the stdout/stderr. That approach is more fiddly code than is really required
for this use-case (where the stdout/stderr is not available incrementally anyway) but we should
make sure that the stdout/stderr is accessible.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message