Finding IP Address of application on CloudBees
I've followed the advice here:
http://wiki.cloudbees.com/bin/view/Main/Finding+out+app+port+and+hostname
public String getIp() throws UnknownHostException {
String hostName = InetAddress.getLocalHost().getHostName();
String urlToRead =
"http://instance-data/latest/meta-data/public-hostname";
String iVeALsoTriedThis = "http://instance-data/latest/meta-data/" +
hostName;
URL url;
HttpURLConnection conn;
BufferedReader rd;
String line;
String result = "";
try {
url = new URL(urlToRead);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
rd = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
while ((line = rd.readLine()) != null) {
result += line;
}
rd.close();
} catch (Exception e) {
e.printStackTrace();
}
return hostName + " ------ " + result;
}
And when using on the homepage a simple tag to obtain the details:
IP: <s:property value="ip"/>
The result I get is this:
IP: ip-10-34-128-137.eu-west-1.compute.internal ------
ec2-46-51-131-172.eu-west-1.compute.amazonaws.com
This was not what I was expecting - even when I tried to access
10.34.128.137 I just get a timeout error. Also pinging 46.51.131.172 gets
timed out and trying to access
ec2-46-51-131-172.eu-west-1.compute.amazonaws.com also brings timout.
I know most of you would consider this trivial, but there's no easy way on
cloudbees to identify the IP of your app from the console, and then
following their (usually clear advice) I get completely lost.
Please, what should I be doing here?
Many thanks,
Ken
No comments:
Post a Comment