You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by bostko <gi...@git.apache.org> on 2017/03/15 15:43:59 UTC

[GitHub] brooklyn-server pull request #596: WinRmCommandSensor default executionDir

GitHub user bostko opened a pull request:

    https://github.com/apache/brooklyn-server/pull/596

    WinRmCommandSensor default executionDir

    Use default dir obtained on the winrm sesion
    until Apache Brooklyn has working concept for RUN_DIR on VanillaWindowsProcess

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/bostko/brooklyn-server winrm-command-sensor-default-dir

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/596.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #596
    
----
commit 3ec766c221aa61f45e6f7a07ba042e6af06509f7
Author: Valentin Aitken <bo...@gmail.com>
Date:   2017-03-15T15:43:27Z

    WinRmCommandSensor default executionDir
    
    Use default dir obtained on the winrm sesion
    until Apache Brooklyn has working concept for RUN_DIR on VanillaWindowsProcess

----


---
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.
---

[GitHub] brooklyn-server pull request #596: WinRmCommandSensor default executionDir

Posted by bostko <gi...@git.apache.org>.
Github user bostko commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/596#discussion_r106206363
  
    --- Diff: software/winrm/src/main/java/org/apache/brooklyn/core/sensor/windows/WinRmCommandSensor.java ---
    @@ -144,15 +144,7 @@ public T apply(String input) {
         public static String makeCommandExecutingInDirectory(String command, String executionDir, Entity entity) {
             String finalCommand = command;
             String execDir = executionDir;
    -        if (Strings.isBlank(execDir)) {
    -            // default to run dir
    -            execDir = entity.getAttribute(BrooklynConfigKeys.RUN_DIR);
    -            // if no run dir, default to home
    -            if (Strings.isBlank(execDir)) {
    -                execDir = "%USERPROFILE%";
    -            }
    -        }
    -        if (!"~".equals(execDir)) {
    +        if (Strings.isNonBlank(execDir) && !"~".equals(execDir)) {
    --- End diff --
    
    That's why empty has the same meaning as `~`.


---
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.
---

[GitHub] brooklyn-server pull request #596: WinRmCommandSensor default executionDir

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/596#discussion_r106203683
  
    --- Diff: software/winrm/src/main/java/org/apache/brooklyn/core/sensor/windows/WinRmCommandSensor.java ---
    @@ -144,15 +144,7 @@ public T apply(String input) {
         public static String makeCommandExecutingInDirectory(String command, String executionDir, Entity entity) {
             String finalCommand = command;
             String execDir = executionDir;
    -        if (Strings.isBlank(execDir)) {
    -            // default to run dir
    -            execDir = entity.getAttribute(BrooklynConfigKeys.RUN_DIR);
    -            // if no run dir, default to home
    -            if (Strings.isBlank(execDir)) {
    -                execDir = "%USERPROFILE%";
    -            }
    -        }
    -        if (!"~".equals(execDir)) {
    +        if (Strings.isNonBlank(execDir) && !"~".equals(execDir)) {
    --- End diff --
    
    That's nice as a temporary patch around the fact that `RUN_DIR` is set to a UNIX-y path. What's the default folder we get on login? Is there a risk in executing in a protected folder (`C:\Windows\system32`) which will fail the code if it writes to the file system?
    What if we keep the `%USERPROFILE%` default?
    I thought this is executed as powershell, which makes the next line look like it would fail - how does it work then?


---
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.
---

[GitHub] brooklyn-server issue #596: WinRmCommandSensor default executionDir

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the issue:

    https://github.com/apache/brooklyn-server/pull/596
  
    LGTM


---
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.
---

[GitHub] brooklyn-server pull request #596: WinRmCommandSensor default executionDir

Posted by bostko <gi...@git.apache.org>.
Github user bostko commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/596#discussion_r106205545
  
    --- Diff: software/winrm/src/main/java/org/apache/brooklyn/core/sensor/windows/WinRmCommandSensor.java ---
    @@ -144,15 +144,7 @@ public T apply(String input) {
         public static String makeCommandExecutingInDirectory(String command, String executionDir, Entity entity) {
             String finalCommand = command;
             String execDir = executionDir;
    -        if (Strings.isBlank(execDir)) {
    -            // default to run dir
    -            execDir = entity.getAttribute(BrooklynConfigKeys.RUN_DIR);
    -            // if no run dir, default to home
    -            if (Strings.isBlank(execDir)) {
    -                execDir = "%USERPROFILE%";
    -            }
    -        }
    -        if (!"~".equals(execDir)) {
    +        if (Strings.isNonBlank(execDir) && !"~".equals(execDir)) {
    --- End diff --
    
    Default directory is `%USERPROFILE%`.
    You can try by setting a sensor from `command: dir`.
    We already use the same default directory for launch.command and other commands in `VanillaWindowsProcess`.


---
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.
---

[GitHub] brooklyn-server pull request #596: WinRmCommandSensor default executionDir

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/596


---
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.
---