Adds JcloudsLocation.LOOKUP_AWS_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/e6be5b1c Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/e6be5b1c Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/e6be5b1c
Branch: refs/heads/master Commit: e6be5b1c10035e3c0b3a0773e1556f97ae321d69 Parents: 6a1ac3f Author: Aled Sage <[email protected]> Authored: Wed Jun 1 17:34:17 2016 +0100 Committer: Aled Sage <[email protected]> Committed: Mon Jun 6 15:10:09 2016 +0100 ---------------------------------------------------------------------- .../apache/brooklyn/location/jclouds/JcloudsLocation.java | 9 ++++++--- .../brooklyn/location/jclouds/JcloudsLocationConfig.java | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e6be5b1c/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 c87678f..fb68819 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 @@ -3072,9 +3072,10 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im */ protected String getPublicHostname(NodeMetadata node, Optional<HostAndPort> sshHostAndPort, LoginCredentials userCredentials, ConfigBag 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(); - if ("aws-ec2".equals(provider)) { + if ("aws-ec2".equals(provider) && Boolean.TRUE.equals(lookupAwsHostname)) { HostAndPort inferredHostAndPort = null; if (!sshHostAndPort.isPresent()) { try { @@ -3168,12 +3169,14 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im protected String getPrivateHostname(NodeMetadata node, Optional<HostAndPort> sshHostAndPort, LoginCredentials userCredentials, ConfigBag setup) { String provider = (setup != null) ? setup.get(CLOUD_PROVIDER) : null; - if (provider == null) provider= getProvider(); + 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)) { + if ("aws-ec2".equals(provider) && Boolean.TRUE.equals(lookupAwsHostname)) { Maybe<String> result = getPrivateHostnameAws(node, sshHostAndPort, userCredentials, setup); if (result.isPresent()) return result.get(); } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e6be5b1c/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocationConfig.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocationConfig.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocationConfig.java index 1403a9f..35da672 100644 --- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocationConfig.java +++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocationConfig.java @@ -234,6 +234,12 @@ public interface JcloudsLocationConfig extends CloudLocationConfig { + "This config is beta; its default could be changed and/or the option removed in an upcoming release.", true); + @Beta + public static final ConfigKey<Boolean> LOOKUP_AWS_HOSTNAME = ConfigKeys.newBooleanConfigKey( + "lookupAwsHostname", + "Whether to lookup the AWS hostname (via a command on the VM), or to just use the IP.", + true); + public static final ConfigKey<JcloudsPortForwarderExtension> PORT_FORWARDER = ConfigKeys.newConfigKey( JcloudsPortForwarderExtension.class, "portforwarding.forwarder", "The port-forwarder to use");
