You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2015/07/27 12:25:01 UTC

[1/4] incubator-brooklyn git commit: Fix REST api location returning config

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 3e11e3eaa -> c2e55c0f0


Fix REST api location returning config


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

Branch: refs/heads/master
Commit: 4c7be5850226243bc34e84ac4fe880816d6631f9
Parents: 2f9e0e6
Author: Aled Sage <al...@gmail.com>
Authored: Mon Jul 13 16:48:32 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Jul 13 17:36:24 2015 +0100

----------------------------------------------------------------------
 .../rest/transform/LocationTransformer.java     |  2 +-
 .../rest/resources/LocationResourceTest.java    | 35 ++++++++++++++++----
 2 files changed, 30 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c7be585/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java b/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
index 6df1d4f..32304bc 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
@@ -178,7 +178,7 @@ public class LocationTransformer {
                     configOrig.put(LocationConfigKeys.DISPLAY_NAME.getName(), configExtra.get(LocationConfigKeys.DISPLAY_NAME.getName()));
             }
         }
-        Map<String, ?> config = level!=LocationDetailLevel.NONE ? null : copyConfig(configOrig, level);
+        Map<String, ?> config = level==LocationDetailLevel.NONE ? null : copyConfig(configOrig, level);
         
         return new LocationSummary(
             l.getId(),

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c7be585/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java b/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
index 4ff3a5d..11a889c 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
@@ -34,12 +34,6 @@ import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import brooklyn.location.jclouds.JcloudsLocation;
-import brooklyn.rest.domain.CatalogLocationSummary;
-import brooklyn.rest.domain.LocationSummary;
-import brooklyn.rest.testing.BrooklynRestResourceTest;
-import brooklyn.test.Asserts;
-
 import com.google.api.client.repackaged.com.google.common.base.Joiner;
 import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
@@ -48,6 +42,14 @@ import com.google.common.collect.Iterables;
 import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.GenericType;
 
+import brooklyn.location.LocationSpec;
+import brooklyn.location.basic.SimulatedLocation;
+import brooklyn.location.jclouds.JcloudsLocation;
+import brooklyn.rest.domain.CatalogLocationSummary;
+import brooklyn.rest.domain.LocationSummary;
+import brooklyn.rest.testing.BrooklynRestResourceTest;
+import brooklyn.test.Asserts;
+
 @Test(singleThreaded = true)
 public class LocationResourceTest extends BrooklynRestResourceTest {
 
@@ -148,6 +150,27 @@ public class LocationResourceTest extends BrooklynRestResourceTest {
         assertEquals(location.getSpec(), "brooklyn.catalog:"+locationName+":"+locationVersion);
     }
 
+    @SuppressWarnings("deprecation")
+    @Test
+    public void testGetLocationConfig() {
+        SimulatedLocation parentLoc = (SimulatedLocation) getManagementContext().getLocationManager().createLocation(LocationSpec.create(SimulatedLocation.class)
+                .configure("myParentKey", "myParentVal"));
+        SimulatedLocation loc = (SimulatedLocation) getManagementContext().getLocationManager().createLocation(LocationSpec.create(SimulatedLocation.class)
+                .parent(parentLoc)
+                .configure("mykey", "myval")
+                .configure("password", "mypassword"));
+    
+        // "full" means including-inherited, filtered to exclude secrets
+        URI uriFull = URI.create("/v1/locations/"+loc.getId()+"?full=true");
+        LocationSummary summaryFull = client().resource(uriFull).get(LocationSummary.class);
+        assertEquals(summaryFull.getConfig(), ImmutableMap.of("mykey", "myval", "myParentKey", "myParentVal"), "conf="+summaryFull.getConfig());
+        
+        // Default is local-only, filtered to exclude secrets
+        URI uriDefault = URI.create("/v1/locations/"+loc.getId());
+        LocationSummary summaryDefault = client().resource(uriDefault).get(LocationSummary.class);
+        assertEquals(summaryDefault.getConfig(), ImmutableMap.of("mykey", "myval"), "conf="+summaryDefault.getConfig());
+    }
+
     @Test(dependsOnMethods = { "testAddLegacyLocationDefinition" })
     @Deprecated
     public void testDeleteLocation() {


[3/4] incubator-brooklyn git commit: Fix os-details.sh for suse, and test on aws

Posted by ri...@apache.org.
Fix os-details.sh for suse, and test on aws


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

Branch: refs/heads/master
Commit: cee066e75d5994d4d5efbf706530048c1cde6ef5
Parents: b2d3f33
Author: Aled Sage <al...@gmail.com>
Authored: Mon Jul 13 16:32:58 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Jul 13 17:36:24 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/location/basic/os-details.sh       | 12 +++++
 .../brooklyn/entity/AbstractEc2LiveTest.java    |  6 +++
 .../machine/MachineEntityEc2LiveTest.java       | 57 ++++++++++++++++++++
 3 files changed, 75 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cee066e7/core/src/main/resources/brooklyn/location/basic/os-details.sh
----------------------------------------------------------------------
diff --git a/core/src/main/resources/brooklyn/location/basic/os-details.sh b/core/src/main/resources/brooklyn/location/basic/os-details.sh
index 8021516..d6f84c3 100755
--- a/core/src/main/resources/brooklyn/location/basic/os-details.sh
+++ b/core/src/main/resources/brooklyn/location/basic/os-details.sh
@@ -56,6 +56,18 @@ if [ -z $VERSION_ID ] && [ -f /etc/debian_version ]; then
     VERSION_ID=$(cat /etc/debian_version)
 fi
 
+# Suse doesn't have os-release or lsb_release
+if [ -z $VERSION_ID ] && [ -f /etc/SuSE-release  ]; then
+    NAME=Suse
+    VERSION_MAJOR=$(cat /etc/SuSE-release | grep VERSION | sed 's/VERSION \= //')
+    VERSION_PATCH=$(cat /etc/SuSE-release | grep PATCHLEVEL | sed 's/PATCHLEVEL \= //')
+    if [ -z $VERSION_PATCH ]; then
+        VERSION_ID=${VERSION_MAJOR}
+    else
+        VERSION_ID=${VERSION_MAJOR}.${VERSION_PATCH}
+    fi
+fi
+
 # Hardware info
 # Is the loss of precision converting bytes and kilobytes to megabytes acceptable?
 # We can do floating point calculations with precision with the bc program, but it

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cee066e7/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java b/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
index 7cf3ebc..daef751 100644
--- a/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
+++ b/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
@@ -119,6 +119,12 @@ public abstract class AbstractEc2LiveTest extends BrooklynAppLiveTestSupport {
         runTest(ImmutableMap.of("imageId", "us-east-1/ami-a35a33ca", "hardwareId", SMALL_HARDWARE_ID, JcloudsLocationConfig.OPEN_IPTABLES.getName(), "true"));
     }
     
+    @Test(groups = {"Live"})
+    public void test_Suse_11sp3() throws Exception {
+        // Image: {id=us-east-1/ami-c08fcba8, providerId=ami-c08fcba8, name=suse-sles-11-sp3-v20150127-pv-ssd-x86_64, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=suse, arch=paravirtual, version=, description=amazon/suse-sles-11-sp3-v20150127-pv-ssd-x86_64, is64Bit=true}, description=SUSE Linux Enterprise Server 11 Service Pack 3 (PV, 64-bit, SSD-Backed), version=x86_64, status=AVAILABLE[available], loginUser=root, userMetadata={owner=013907871322, rootDeviceType=ebs, virtualizationType=paravirtual, hypervisor=xen}}
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-c08fcba8", "hardwareId", SMALL_HARDWARE_ID, "loginUser", "ec2-user"));//, JcloudsLocationConfig.OPEN_IPTABLES.getName(), "true"));
+    }
+    
     protected void runTest(Map<String,?> flags) throws Exception {
         Map<String,?> allFlags = MutableMap.<String,Object>builder()
                 .put("tags", ImmutableList.of(getClass().getName()))

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cee066e7/software/base/src/test/java/brooklyn/entity/machine/MachineEntityEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/machine/MachineEntityEc2LiveTest.java b/software/base/src/test/java/brooklyn/entity/machine/MachineEntityEc2LiveTest.java
new file mode 100644
index 0000000..4f792aa
--- /dev/null
+++ b/software/base/src/test/java/brooklyn/entity/machine/MachineEntityEc2LiveTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.entity.machine;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+import brooklyn.entity.AbstractEc2LiveTest;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.Location;
+import brooklyn.test.Asserts;
+
+public class MachineEntityEc2LiveTest extends AbstractEc2LiveTest {
+
+    @Override
+    protected void doTest(Location loc) throws Exception {
+        final MachineEntity server = app.createAndManageChild(EntitySpec.create(MachineEntity.class));
+        
+        app.start(ImmutableList.of(loc));
+        
+        Asserts.succeedsEventually(new Runnable() {
+            @Override public void run() {
+                assertNotNull(server.getAttribute(MachineEntity.UPTIME));
+                assertNotNull(server.getAttribute(MachineEntity.LOAD_AVERAGE));
+                assertNotNull(server.getAttribute(MachineEntity.CPU_USAGE));
+                assertNotNull(server.getAttribute(MachineEntity.FREE_MEMORY));
+                assertNotNull(server.getAttribute(MachineEntity.TOTAL_MEMORY));
+                assertNotNull(server.getAttribute(MachineEntity.USED_MEMORY));
+            }});
+        
+        String result = server.execCommand("MY_ENV=myval && echo start $MY_ENV");
+        assertTrue(result.contains("start myval"), "result="+result);
+    }
+    
+    @Test(enabled=false)
+    public void testDummy() {} // Convince testng IDE integration that this really does have test methods
+}


[4/4] incubator-brooklyn git commit: Merge and close #743

Posted by ri...@apache.org.
Merge and close #743


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

Branch: refs/heads/master
Commit: c2e55c0f0ab9eb5818fc25a0a75457579554353f
Parents: 3e11e3e 4c7be58
Author: Richard Downer <ri...@apache.org>
Authored: Mon Jul 27 11:24:25 2015 +0100
Committer: Richard Downer <ri...@apache.org>
Committed: Mon Jul 27 11:24:25 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/location/basic/os-details.sh       | 12 +++++
 .../location/jclouds/JcloudsLocation.java       | 12 ++++-
 .../brooklyn/entity/AbstractEc2LiveTest.java    |  6 +++
 .../machine/MachineEntityEc2LiveTest.java       | 57 ++++++++++++++++++++
 .../rest/transform/LocationTransformer.java     |  2 +-
 .../rest/resources/LocationResourceTest.java    | 35 +++++++++---
 6 files changed, 115 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c2e55c0f/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------


[2/4] incubator-brooklyn git commit: Fix jclouds createUser, with password override

Posted by ri...@apache.org.
Fix jclouds createUser, with password override

Previously if the createUser was configured to use a specific password
for that new user, then it would also try to login to run the
createUser command using that password (rather that use the contents
of the initialCredentials).


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

Branch: refs/heads/master
Commit: 2f9e0e66ccf0dc92d526cb67b87bbf8e39d8551c
Parents: cee066e
Author: Aled Sage <al...@gmail.com>
Authored: Mon Jul 13 16:35:07 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Jul 13 17:36:24 2015 +0100

----------------------------------------------------------------------
 .../java/brooklyn/location/jclouds/JcloudsLocation.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f9e0e66/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index 214f946..966cb4a 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -1531,8 +1531,16 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
                 sshProps.put("user", initialUser);
                 sshProps.put("address", address);
                 sshProps.put("port", port);
-                if (initialPassword.isPresent()) sshProps.put("password", initialPassword.get());
-                if (initialPrivateKey.isPresent()) sshProps.put("privateKeyData", initialPrivateKey.get());
+                if (initialPassword.isPresent()) {
+                    sshProps.put("password", initialPassword.get());
+                } else {
+                    sshProps.remove("password");
+                }
+                if (initialPrivateKey.isPresent()) {
+                    sshProps.put("privateKeyData", initialPrivateKey.get());
+                } else {
+                    sshProps.remove("privateKeyData");
+                }
     
                 // TODO Retrying lots of times as workaround for vcloud-director. There the guest customizations
                 // can cause the VM to reboot shortly after it was ssh'able.