brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [1/3] git commit: Adds SoftwareProcess.SSH_ADDRESS (user@ip:port)
Date Sun, 01 Jun 2014 23:15:11 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master d39186b1b -> 64d3fec7f


Adds SoftwareProcess.SSH_ADDRESS (user@ip:port)

- particularly useful for docker, where the ssh port is mapped so
  no each way of finding out that port otherwise

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

Branch: refs/heads/master
Commit: 4156b4e7edae040a5af3b9052faef6a96071b08d
Parents: 3dfcd6f
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu May 29 20:38:32 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu May 29 20:38:32 2014 +0100

----------------------------------------------------------------------
 .../main/java/brooklyn/entity/basic/Attributes.java   |  1 +
 .../java/brooklyn/entity/basic/SoftwareProcess.java   |  1 +
 .../software/MachineLifecycleEffectorTasks.java       |  6 ++++++
 .../entity/basic/SoftwareProcessEntityTest.java       | 14 +++++++++++++-
 4 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4156b4e7/core/src/main/java/brooklyn/entity/basic/Attributes.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/Attributes.java b/core/src/main/java/brooklyn/entity/basic/Attributes.java
index 636f7ea..2f5f0ad 100644
--- a/core/src/main/java/brooklyn/entity/basic/Attributes.java
+++ b/core/src/main/java/brooklyn/entity/basic/Attributes.java
@@ -56,6 +56,7 @@ public interface Attributes {
 
     AttributeSensor<String> HOSTNAME = Sensors.newStringSensor( "host.name", "Host
name");
     AttributeSensor<String> ADDRESS = Sensors.newStringSensor( "host.address", "Host
IP address");
+    AttributeSensor<String> SSH_ADDRESS = Sensors.newStringSensor("host.sshAddress",
"user@host:port for ssh'ing (or null if inappropriate)");
     AttributeSensor<String> SUBNET_HOSTNAME = Sensors.newStringSensor( "host.subnet.hostname",
"Host name as known internally in " +
     		"the subnet where it is running (if different to host.name)");
     AttributeSensor<String> SUBNET_ADDRESS = Sensors.newStringSensor( "host.subnet.address",
"Host address as known internally in " +

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4156b4e7/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
index 7e60822..e6cbda7 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
@@ -19,6 +19,7 @@ public interface SoftwareProcess extends Entity, Startable {
 
     public static final AttributeSensor<String> HOSTNAME = Attributes.HOSTNAME;
     public static final AttributeSensor<String> ADDRESS = Attributes.ADDRESS;
+    public static final AttributeSensor<String> SSH_ADDRESS = Attributes.SSH_ADDRESS;
     public static final AttributeSensor<String> SUBNET_HOSTNAME = Attributes.SUBNET_HOSTNAME;
     public static final AttributeSensor<String> SUBNET_ADDRESS = Attributes.SUBNET_ADDRESS;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4156b4e7/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
index aff142d..5924f30 100644
--- a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
@@ -56,6 +56,7 @@ import com.google.common.base.Supplier;
 import com.google.common.base.Suppliers;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
+import com.google.common.net.HostAndPort;
 
 /** 
  * Default skeleton for start/stop/restart tasks on machines.
@@ -278,6 +279,11 @@ public abstract class MachineLifecycleEffectorTasks {
             if (la.isPresent()) entity().setAttribute(Attributes.SUBNET_ADDRESS, la.get());
             entity().setAttribute(Attributes.HOSTNAME, machine.getAddress().getHostName());
             entity().setAttribute(Attributes.ADDRESS, machine.getAddress().getHostAddress());
+            if (machine instanceof SshMachineLocation) {
+                SshMachineLocation sshMachine = (SshMachineLocation) machine;
+                String sshAddress = sshMachine.getUser() + "@"+sshMachine.getAddress().getHostName()+":"+sshMachine.getPort();
+                entity().setAttribute(Attributes.SSH_ADDRESS, sshAddress);
+            }
             
             resolveOnBoxDir(entity(), machine);            
             preStartCustom(machine);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4156b4e7/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
index 22fb334..cdc552d 100644
--- a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
+++ b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
@@ -1,5 +1,7 @@
 package brooklyn.entity.basic;
 
+import static org.testng.Assert.assertEquals;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -54,9 +56,19 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport
{
     }
 
     @Test
+    public void testSetsMachineAttributes() throws Exception {
+        MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class));
+        entity.start(ImmutableList.of(loc));
+        
+        assertEquals(entity.getAttribute(SoftwareProcess.HOSTNAME), machine.getAddress().getHostName());
+        assertEquals(entity.getAttribute(SoftwareProcess.ADDRESS), machine.getAddress().getHostAddress());
+        assertEquals(entity.getAttribute(SoftwareProcess.SSH_ADDRESS), machine.getUser()
+ "@" + machine.getAddress().getHostName() + ":" + machine.getPort());
+        assertEquals(entity.getAttribute(SoftwareProcess.PROVISIONING_LOCATION), loc);
+    }
+
+    @Test
     public void testProcessTemplateWithExtraSubstitutions() throws Exception {
         MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class));
-        Entities.manage(entity);
         entity.start(ImmutableList.of(loc));
         SimulatedDriver driver = (SimulatedDriver) entity.getDriver();
         Map<String,String> substitutions = MutableMap.of("myname","peter");


Mime
View raw message