Repository: brooklyn-server Updated Branches: refs/heads/master baf807097 -> f0fe753c2
Retrieve the right AWS metadata for private hostname Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/8877368a Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/8877368a Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/8877368a Branch: refs/heads/master Commit: 8877368aa4c04e21eecd167538f878c4e0681900 Parents: 1ae9aaa Author: Thomas Bouron <[email protected]> Authored: Mon Oct 2 13:39:21 2017 +0200 Committer: Thomas Bouron <[email protected]> Committed: Mon Oct 2 17:20:28 2017 +0200 ---------------------------------------------------------------------- .../brooklyn/location/jclouds/JcloudsLocation.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8877368a/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 8c01e24..450ba79 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 @@ -2829,16 +2829,11 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im return getPublicHostname(node, sshHostAndPort, userCredentials, setup); } - 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(); + // 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; } Optional<String> preferredAddress = sshHostAndPort.isPresent() ? Optional.of(sshHostAndPort.get().getHostText()) : Optional.<String>absent();
