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 2016/11/19 23:28:09 UTC
[1/3] brooklyn-server git commit: Use subnet IP on machine locations
that dont implement HasSubnetHostname
Repository: brooklyn-server
Updated Branches:
refs/heads/master d7eb99e10 -> 5de342c7a
Use subnet IP on machine locations that dont implement HasSubnetHostname
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/acb14e7e
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/acb14e7e
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/acb14e7e
Branch: refs/heads/master
Commit: acb14e7e76af7556d2ce17d0a1f655cdb22b1112
Parents: d7eb99e
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Fri Nov 18 17:18:43 2016 +0000
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Sat Nov 19 17:01:25 2016 +0000
----------------------------------------------------------------------
.../java/org/apache/brooklyn/core/location/Machines.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/acb14e7e/core/src/main/java/org/apache/brooklyn/core/location/Machines.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/location/Machines.java b/core/src/main/java/org/apache/brooklyn/core/location/Machines.java
index c4eb84c..9163694 100644
--- a/core/src/main/java/org/apache/brooklyn/core/location/Machines.java
+++ b/core/src/main/java/org/apache/brooklyn/core/location/Machines.java
@@ -49,8 +49,13 @@ public class Machines {
hostname = ((HasSubnetHostname) where).getSubnetHostname();
}
if (hostname == null && where instanceof MachineLocation) {
- InetAddress addr = ((MachineLocation) where).getAddress();
- if (addr != null) hostname = addr.getHostAddress();
+ Maybe<String> subnetIp = getSubnetIp(where);
+ if (subnetIp.isPresent()) {
+ hostname = subnetIp.get();
+ } else {
+ InetAddress addr = ((MachineLocation) where).getAddress();
+ if (addr != null) hostname = addr.getHostAddress();
+ }
}
log.debug("computed subnet hostname {} for {}", hostname, where);
// TODO if Maybe.absent(message) appears, could/should use that
[2/3] brooklyn-server git commit: Fix
testFindSubnetHostnameFromLocation test to use private address
Posted by al...@apache.org.
Fix testFindSubnetHostnameFromLocation test to use private address
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/4f3a3da9
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/4f3a3da9
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/4f3a3da9
Branch: refs/heads/master
Commit: 4f3a3da979c4b0a6011bf2f2dcdfa0e3d873d1fa
Parents: acb14e7
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Sat Nov 19 15:33:45 2016 +0000
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Sat Nov 19 18:00:47 2016 +0000
----------------------------------------------------------------------
.../brooklyn/core/location/MachinesTest.java | 27 ++++++++++++++------
1 file changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4f3a3da9/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java b/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
index 19c88df..cf893e4 100644
--- a/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
@@ -87,24 +87,29 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(l1, l2), SshMachineLocation.class).get(), l1);
assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(l2), LocalhostMachine.class).isPresent());
}
-
+
@Test
public void testFindSubnetIpFromAttribute() throws Exception {
TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
.location(sshMachineSpec));
entity.sensors().set(Attributes.SUBNET_ADDRESS, "myaddr");
-
assertEquals(Machines.findSubnetIp(entity).get(), "myaddr");
}
-
+
@Test
public void testFindSubnetIpFromLocation() throws Exception {
TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
.location(sshMachineSpec));
-
assertEquals(Machines.findSubnetIp(entity).get(), privateAddr);
}
-
+
+ @Test
+ public void testFindSubnetIpFromLocationWithoutPrivate() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachineWithoutPrivateSpec));
+ assertEquals(Machines.findSubnetIp(entity).get(), publicAddr);
+ }
+
@Test
public void testFindSubnetHostnameFromAttribute() throws Exception {
TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
@@ -112,15 +117,21 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
entity.sensors().set(Attributes.SUBNET_HOSTNAME, "myval");
assertEquals(Machines.findSubnetHostname(entity).get(), "myval");
}
-
+
@Test
public void testFindSubnetHostnameFromLocation() throws Exception {
TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
.location(sshMachineSpec));
-
+ assertEquals(Machines.findSubnetHostname(entity).get(), privateAddr);
+ }
+
+ @Test
+ public void testFindSubnetHostnameFromLocationWithoutPrivate() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachineWithoutPrivateSpec));
assertEquals(Machines.findSubnetHostname(entity).get(), publicAddr);
}
-
+
@Test
public void testFindSubnetOrPrivateIpWithAddressAttributePrefersLocationPrivateIp() throws Exception {
TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
[3/3] brooklyn-server git commit: This closes #445
Posted by al...@apache.org.
This closes #445
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/5de342c7
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/5de342c7
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/5de342c7
Branch: refs/heads/master
Commit: 5de342c7a4c4c53af41ded14e4161635eb370d7d
Parents: d7eb99e 4f3a3da
Author: Aled Sage <al...@gmail.com>
Authored: Sat Nov 19 23:27:54 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Nov 19 23:27:54 2016 +0000
----------------------------------------------------------------------
.../apache/brooklyn/core/location/Machines.java | 9 +++++--
.../brooklyn/core/location/MachinesTest.java | 27 ++++++++++++++------
2 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------