Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2D651200D2D for ; Fri, 27 Oct 2017 14:37:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2C0FD160BDC; Fri, 27 Oct 2017 12:37:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 731981609E9 for ; Fri, 27 Oct 2017 14:37:14 +0200 (CEST) Received: (qmail 32201 invoked by uid 500); 27 Oct 2017 12:37:13 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 32192 invoked by uid 99); 27 Oct 2017 12:37:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Oct 2017 12:37:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8D5D3DFB6F; Fri, 27 Oct 2017 12:37:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aledsage@apache.org To: commits@brooklyn.apache.org Date: Fri, 27 Oct 2017 12:37:13 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] brooklyn-server git commit: Revert "Retrieve the right AWS metadata for private hostname" archived-at: Fri, 27 Oct 2017 12:37:15 -0000 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 Authored: Fri Oct 27 13:18:57 2017 +0100 Committer: graeme.miller 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 result = getHostnameAws(node, sshHostAndPort, userCredentials, setup); + if (result.isPresent()) return result.get(); } Optional preferredAddress = sshHostAndPort.isPresent() ? Optional.of(sshHostAndPort.get().getHostText()) : Optional.absent();