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

[1/3] incubator-brooklyn git commit: Clarify instructions

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master e0cc1a646 -> 2835106ac


Clarify instructions

The current instructions are confusing.

Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/70ea692d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/70ea692d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/70ea692d

Branch: refs/heads/master
Commit: 70ea692d72e63cbda882e7365665df341ad84af6
Parents: e0cc1a6
Author: jadelus <jo...@jadelus.com>
Authored: Tue Feb 17 19:53:58 2015 -0800
Committer: jadelus <jo...@jadelus.com>
Committed: Tue Feb 17 19:53:58 2015 -0800

----------------------------------------------------------------------
 docs/website/download/index.md | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/70ea692d/docs/website/download/index.md
----------------------------------------------------------------------
diff --git a/docs/website/download/index.md b/docs/website/download/index.md
index f997b92..18ba08a 100644
--- a/docs/website/download/index.md
+++ b/docs/website/download/index.md
@@ -19,14 +19,19 @@ We do not yet have an official binary package for Apache Brooklyn. We plan to ad
 
 However, it is relatively easy to create the binary package from source code, if you have a working recent JDK and Maven 3.
 
-**1)** Unpack `apache-brooklyn-{{ site.brooklyn-stable-version }}.tar.gz` and go into this directory:
+**1)** Unpack `apache-brooklyn-{{ site.brooklyn-stable-version }}.tar.gz`
 
 {% highlight bash %}
 tar xvfz apache-brooklyn-{{ site.brooklyn-stable-version }}.tar.gz
+{% endhighlight %}
+
+**2)** Move to the newly created `apache-brooklyn-{{ site.brooklyn-stable-version }}` folder:
+
+{% highlight bash %}
 cd apache-brooklyn-{{ site.brooklyn-stable-version }}
 {% endhighlight %}
 
-**2)** Run this command in the `apache-brooklyn-{{ site.brooklyn-stable-version }}` folder:
+**3)** Run this command in the `apache-brooklyn-{{ site.brooklyn-stable-version }}` folder:
 
 {% highlight bash %}
 mvn clean install -DskipTests


[2/3] incubator-brooklyn git commit: Adds getConfig method to server REST API to allow client code to read properties

Posted by al...@apache.org.
Adds getConfig method to server REST API to allow client code to read properties


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/5ee01b8a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/5ee01b8a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/5ee01b8a

Branch: refs/heads/master
Commit: 5ee01b8a774c8dd0f09bdef5dfe55d8efde88df5
Parents: e0cc1a6
Author: Martin Harris <gi...@nakomis.com>
Authored: Mon Feb 16 11:13:03 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Feb 18 10:45:37 2015 +0000

----------------------------------------------------------------------
 .../main/java/brooklyn/rest/api/ServerApi.java  | 15 ++++++++
 .../brooklyn/rest/resources/ServerResource.java | 11 ++++++
 .../rest/resources/ServerResourceTest.java      | 40 +++++++++++++++++++-
 3 files changed, 65 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5ee01b8a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java
index 6621ce1..624c9db 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java
@@ -26,6 +26,7 @@ import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
@@ -38,6 +39,8 @@ import brooklyn.rest.domain.HighAvailabilitySummary;
 import brooklyn.rest.domain.VersionSummary;
 
 import com.google.common.annotations.Beta;
+import com.wordnik.swagger.core.ApiError;
+import com.wordnik.swagger.core.ApiErrors;
 import com.wordnik.swagger.core.ApiOperation;
 import com.wordnik.swagger.core.ApiParam;
 
@@ -87,6 +90,18 @@ public interface ServerApi {
             multiValueResponse = false)
     public String getStatus();
 
+    @GET
+    @Path("/config/{configKey}")
+    @ApiOperation(value = "Get the value of the specified config key from brooklyn properties")
+    @ApiErrors(value = {
+            // TODO: This should probably return a 404 if the key is not present, and should return a predictable
+            // value if the value is not set. Behaviour should be consistent with EntityConfigApi.get()
+            @ApiError(code = 204, reason = "Could not find config key")
+    })
+    public String getConfig(
+            @ApiParam(value = "Config key ID", required = true)
+            @PathParam("configKey") String configKey);
+
     @Deprecated /** @deprecated since 0.7.0 use /ha/states */
     @GET
     @Path("/highAvailability")

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5ee01b8a/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java b/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
index caacc29..6f8465e 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
@@ -33,6 +33,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import brooklyn.config.ConfigKey;
+import brooklyn.entity.basic.ConfigKeys;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -253,6 +255,15 @@ public class ServerResource extends AbstractBrooklynRestResource implements Serv
         return getHighAvailabilityNodeState().toString();
     }
 
+    @Override
+    public String getConfig(String configKey) {
+        if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_ALL_SERVER_INFO, null)) {
+            throw WebResourceUtils.unauthorized("User '%s' is not authorized for this operation", Entitlements.getEntitlementContext().user());
+        }
+        ConfigKey<String> config = ConfigKeys.newStringConfigKey(configKey);
+        return mgmt().getConfig().getConfig(config);
+    }
+
     @Deprecated
     @Override
     public HighAvailabilitySummary getHighAvailability() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5ee01b8a/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java b/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
index d7411c3..26491b3 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
@@ -21,10 +21,16 @@ package brooklyn.rest.resources;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
 import java.util.concurrent.atomic.AtomicInteger;
 
+import brooklyn.config.BrooklynProperties;
+import brooklyn.management.internal.ManagementContextInternal;
+import com.google.common.collect.ImmutableMap;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.Test;
@@ -97,5 +103,37 @@ public class ServerResourceTest extends BrooklynRestResourceTest {
                 assertFalse(getManagementContext().isRunning());
             }});
     }
-    
+
+    @Test
+    void testGetConfig() throws Exception {
+        ((ManagementContextInternal)getManagementContext()).getBrooklynProperties().put("foo.bar.baz", "quux");
+        try {
+            assertEquals(client().resource("/v1/server/config/foo.bar.baz").get(String.class), "quux");
+        } finally {
+            ((ManagementContextInternal)getManagementContext()).getBrooklynProperties().remove("foo.bar.baz");
+        }
+    }
+
+    @Test
+    void testGetMissingConfigThrowsException() throws Exception {
+        final String key = "foo.bar.baz";
+        BrooklynProperties properties = ((ManagementContextInternal)getManagementContext()).getBrooklynProperties();
+        Object existingValue = null;
+        boolean keyAlreadyPresent = false;
+        String response = null;
+        if (properties.containsKey(key)) {
+            existingValue = properties.remove(key);
+            keyAlreadyPresent = true;
+        }
+        try {
+            response = client().resource("/v1/server/config/" + key).get(String.class);
+            Asserts.fail("Expected call to /v1/server/config/" + key + " to fail with status 404, instead server returned " + response);
+        } catch (UniformInterfaceException e) {
+            assertEquals(e.getResponse().getStatus(), 204);
+        } finally {
+            if (keyAlreadyPresent) {
+                properties.put(key, existingValue);
+            }
+        }
+    }
 }


[3/3] incubator-brooklyn git commit: This closes #517

Posted by al...@apache.org.
This closes #517


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/2835106a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/2835106a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/2835106a

Branch: refs/heads/master
Commit: 2835106acfce26f23fb08e915c2a7ae0fef7a807
Parents: 5ee01b8 70ea692
Author: Aled Sage <al...@gmail.com>
Authored: Wed Feb 18 10:45:38 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Feb 18 10:45:38 2015 +0000

----------------------------------------------------------------------
 docs/website/download/index.md | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------