Repository: brooklyn-server
Updated Branches:
  refs/heads/master e73ee2912 -> 5eb08b262


Revert "Retrieve the right AWS metadata for private hostname"

This reverts commit 8877368aa4c04e21eecd167538f878c4e0681900.


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

Branch: refs/heads/master
Commit: 2fb23337d48611a5cf9deb061cbd29f7b7137718
Parents: e73ee29
Author: graeme.miller <[email protected]>
Authored: Fri Oct 27 13:18:57 2017 +0100
Committer: graeme.miller <[email protected]>
Committed: Fri Oct 27 13:18:57 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2fb23337/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
index 39ccc52..80e289a 100644
--- 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
+++ 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
@@ -2827,11 +2827,16 @@ public class JcloudsLocation extends 
AbstractCloudMachineProvisioningLocation im
             return getPublicHostname(node, sshHostAndPort, userCredentials, 
setup);
         }
 
-        // NodeMetadata.getHostname() is supposed to return the private 
hostname. If it's not null, we want to prioritise
-        // this, otherwise we call getPrivateHostnameGeneric()
-        final String hostname = node.getHostname();
-        if (hostname != null) {
-            return hostname;
+        String provider = (setup != null) ? setup.get(CLOUD_PROVIDER) : null;
+        Boolean lookupAwsHostname = (setup != null) ? 
setup.get(LOOKUP_AWS_HOSTNAME) : null;
+        if (provider == null) provider = getProvider();
+
+        // TODO Discouraged to do cloud-specific things; think of this code 
for aws as an
+        // exceptional situation rather than a pattern to follow. We need a 
better way to
+        // do cloud-specific things.
+        if ("aws-ec2".equals(provider) && 
Boolean.TRUE.equals(lookupAwsHostname)) {
+            Maybe<String> result = getHostnameAws(node, sshHostAndPort, 
userCredentials, setup);
+            if (result.isPresent()) return result.get();
         }
 
         Optional<String> preferredAddress = sshHostAndPort.isPresent() ? 
Optional.of(sshHostAndPort.get().getHostText()) : Optional.<String>absent();

Reply via email to