You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:48:45 UTC

[15/50] brooklyn-server git commit: correct sudo invocation of backgrounded commands. review comments, tidy method names.

correct sudo invocation of backgrounded commands. review comments, tidy method names.


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2cfa451a
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2cfa451a
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2cfa451a

Branch: refs/heads/0.4.0
Commit: 2cfa451af4b57c6e01701b302000a1e3ea88658f
Parents: d0527fa
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Sep 28 01:09:59 2012 -0400
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Sep 28 01:21:36 2012 -0400

----------------------------------------------------------------------
 .../brooklyn/location/basic/LocationRegistry.java     |  2 +-
 .../brooklyn/util/text/QuotedStringTokenizer.java     |  2 +-
 .../brooklyn/util/text/QuotedStringTokenizerTest.java | 14 +++++++-------
 .../entity/basic/lifecycle/CommonCommands.java        |  4 ++--
 4 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2cfa451a/core/src/main/java/brooklyn/location/basic/LocationRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/LocationRegistry.java b/core/src/main/java/brooklyn/location/basic/LocationRegistry.java
index 8fe9393..4b5c9de 100644
--- a/core/src/main/java/brooklyn/location/basic/LocationRegistry.java
+++ b/core/src/main/java/brooklyn/location/basic/LocationRegistry.java
@@ -98,7 +98,7 @@ public class LocationRegistry {
     private List<String> expandCommaSeparateLocationList(String id) {
         return WildcardGlobs.getGlobsAfterBraceExpansion("{"+id+"}", false, PhraseTreatment.INTERIOR_NOT_EXPANDABLE, PhraseTreatment.INTERIOR_NOT_EXPANDABLE);
         // don't do this, it tries to expand commas inside parentheses which is not good!
-//        QuotedStringTokenizer.builder().addDelimiterChars(",").tokenizeAll((String)id);
+//        QuotedStringTokenizer.builder().addDelimiterChars(",").buildList((String)id);
     }
     
     public Map getProperties() {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2cfa451a/core/src/main/java/brooklyn/util/text/QuotedStringTokenizer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/text/QuotedStringTokenizer.java b/core/src/main/java/brooklyn/util/text/QuotedStringTokenizer.java
index 52b1f45..9677662 100644
--- a/core/src/main/java/brooklyn/util/text/QuotedStringTokenizer.java
+++ b/core/src/main/java/brooklyn/util/text/QuotedStringTokenizer.java
@@ -58,7 +58,7 @@ public class QuotedStringTokenizer {
 	    public QuotedStringTokenizer build(String stringToTokenize) {
 	        return new QuotedStringTokenizer(stringToTokenize, quoteChars, includeQuotes, delimiterChars, includeDelimiters);
 	    }
-        public List<String> tokenizeAll(String stringToTokenize) {
+        public List<String> buildList(String stringToTokenize) {
             return new QuotedStringTokenizer(stringToTokenize, quoteChars, includeQuotes, delimiterChars, includeDelimiters).remainderAsList();
         }
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2cfa451a/core/src/test/java/brooklyn/util/text/QuotedStringTokenizerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/text/QuotedStringTokenizerTest.java b/core/src/test/java/brooklyn/util/text/QuotedStringTokenizerTest.java
index bccfe2d..01f7076 100644
--- a/core/src/test/java/brooklyn/util/text/QuotedStringTokenizerTest.java
+++ b/core/src/test/java/brooklyn/util/text/QuotedStringTokenizerTest.java
@@ -52,23 +52,23 @@ public class QuotedStringTokenizerTest {
 
     @Test
     public void testTokenizingBuilder() throws Exception {
-        Assert.assertEquals(Arrays.asList("foo", "bar"), QuotedStringTokenizer.builder().tokenizeAll("foo bar"));
-        Assert.assertEquals(Arrays.asList("foo,bar"), QuotedStringTokenizer.builder().tokenizeAll("foo,bar"));
-        Assert.assertEquals(Arrays.asList("foo", "bar"), QuotedStringTokenizer.builder().delimiterChars(",").tokenizeAll("foo,bar"));
-        Assert.assertEquals(Arrays.asList("foo", " bar"), QuotedStringTokenizer.builder().delimiterChars(",").tokenizeAll("foo, bar"));
-        Assert.assertEquals(Arrays.asList("foo", "bar"), QuotedStringTokenizer.builder().addDelimiterChars(",").tokenizeAll("foo, bar"));
+        Assert.assertEquals(Arrays.asList("foo", "bar"), QuotedStringTokenizer.builder().buildList("foo bar"));
+        Assert.assertEquals(Arrays.asList("foo,bar"), QuotedStringTokenizer.builder().buildList("foo,bar"));
+        Assert.assertEquals(Arrays.asList("foo", "bar"), QuotedStringTokenizer.builder().delimiterChars(",").buildList("foo,bar"));
+        Assert.assertEquals(Arrays.asList("foo", " bar"), QuotedStringTokenizer.builder().delimiterChars(",").buildList("foo, bar"));
+        Assert.assertEquals(Arrays.asList("foo", "bar"), QuotedStringTokenizer.builder().addDelimiterChars(",").buildList("foo, bar"));
     }
 
     @Test
     public void testCommaInQuotes() throws Exception {
-        List<String> l = QuotedStringTokenizer.builder().addDelimiterChars(",").tokenizeAll("location1,byon:(hosts=\"loc2,loc3\"),location4");
+        List<String> l = QuotedStringTokenizer.builder().addDelimiterChars(",").buildList("location1,byon:(hosts=\"loc2,loc3\"),location4");
         Assert.assertEquals(Arrays.asList("location1", "byon:(hosts=\"loc2,loc3\")", "location4"), l);
     }
 
     /** not implemented yet */
     @Test(enabled=false)
     public void testCommaInParentheses() throws Exception {
-        List<String> l = QuotedStringTokenizer.builder().addDelimiterChars(",").tokenizeAll("location1, byon:(hosts=\"loc2,loc3\",user=foo),location4");
+        List<String> l = QuotedStringTokenizer.builder().addDelimiterChars(",").buildList("location1, byon:(hosts=\"loc2,loc3\",user=foo),location4");
         Assert.assertEquals(Arrays.asList("location1", "byon:(hosts=\"loc2,loc3\",user=foo)", "location4"), l);
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2cfa451a/software/base/src/main/java/brooklyn/entity/basic/lifecycle/CommonCommands.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/lifecycle/CommonCommands.java b/software/base/src/main/java/brooklyn/entity/basic/lifecycle/CommonCommands.java
index 1a8f6cd..f5f567b 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/lifecycle/CommonCommands.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/lifecycle/CommonCommands.java
@@ -45,7 +45,7 @@ public class CommonCommands {
      * <p/>
      * Ensuring non-blocking if password not set by using {@code -S} which reads
      * from stdin routed to {@code /dev/null} and {@code -E} passes the parent
-     * environment in. If already root, simplem runs the command.
+     * environment in. If already root, simply runs the command, wrapped in brackets in case it is backgrounded.
      * <p/>
      * The command is not quoted or escaped in any ways. 
      * If you are doing privileged redirect you may need to pass e.g. "bash -c 'echo hi > file'".
@@ -54,7 +54,7 @@ public class CommonCommands {
      */
     public static String sudo(String command) {
         if (command==null) return null;
-        return format("(test $UID -eq 0 && %s || sudo -E -n -s -- %s)", command, command);
+        return format("(test $UID -eq 0 && ( %s ) || sudo -E -n -s -- %s )", command, command);
     }
 
     /**