Update Tomcat's webapp.url sensor to show the public hostname
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/50194ae7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/50194ae7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/50194ae7 Branch: refs/heads/master Commit: 50194ae71a9925e9b33747b1f52b1bc783f038a9 Parents: a504093 Author: Valentin Aitken <[email protected]> Authored: Thu Oct 15 16:29:11 2015 +0300 Committer: Valentin Aitken <[email protected]> Committed: Thu Nov 5 08:50:54 2015 +0200 ---------------------------------------------------------------------- .../apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50194ae7/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java ---------------------------------------------------------------------- diff --git a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java index 2a149e7..7791418 100644 --- a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java +++ b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java @@ -24,7 +24,9 @@ import java.io.File; import java.net.URI; import java.util.Set; +import com.google.common.net.HostAndPort; import org.apache.brooklyn.core.entity.Attributes; +import org.apache.brooklyn.core.location.access.BrooklynAccessUtils; import org.apache.brooklyn.entity.java.JavaSoftwareProcessSshDriver; import org.apache.brooklyn.location.ssh.SshMachineLocation; import org.apache.brooklyn.util.core.task.DynamicTasks; @@ -93,11 +95,13 @@ public abstract class JavaWebAppSshDriver extends JavaSoftwareProcessSshDriver i if (isProtocolEnabled("https")) { Integer port = getHttpsPort(); checkNotNull(port, "HTTPS_PORT sensors not set; is an acceptable port available?"); - return String.format("https://%s:%s/", getSubnetHostname(), port); + HostAndPort accessibleAddress = BrooklynAccessUtils.getBrooklynAccessibleAddress(getEntity(), port); + return String.format("https://%s:%s/", accessibleAddress.getHostText(), accessibleAddress.getPort()); } else if (isProtocolEnabled("http")) { Integer port = getHttpPort(); checkNotNull(port, "HTTP_PORT sensors not set; is an acceptable port available?"); - return String.format("http://%s:%s/", getSubnetHostname(), port); + HostAndPort accessibleAddress = BrooklynAccessUtils.getBrooklynAccessibleAddress(getEntity(), port); + return String.format("http://%s:%s/", accessibleAddress.getHostText(), accessibleAddress.getPort()); } else { throw new IllegalStateException("HTTP and HTTPS protocols not enabled for "+entity+"; enabled protocols are "+getEnabledProtocols()); }
