Commit e964dbcd authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Fix ip addresses retrieval issue related to bot.whatismyipaddress.com api

parent ba2aa963
Pipeline #17497 passed with stage
in 1 minute and 17 seconds
......@@ -10,6 +10,7 @@ import org.activeeon.morphemic.model.IpVersion;
import org.activeeon.morphemic.service.EntityManagerHelper;
import org.activeeon.morphemic.service.RMConnectionHelper;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.util.InetAddressUtils;
import org.ow2.proactive.resourcemanager.common.NSState;
import org.ow2.proactive.resourcemanager.common.event.RMNodeEvent;
import org.ow2.proactive.resourcemanager.common.event.dto.RMStateFull;
......@@ -387,7 +388,11 @@ public class PAResourceManagerGateway {
60000);
String publicIPAddr = taskResult.getValue().toString();
LOGGER.info("Task result value to string: " + publicIPAddr);
if (!InetAddressUtils.isIPv4Address(publicIPAddr)) {
LOGGER.warn(String.format("IPAddrGetter job could not retrieve the public ip for deployment [%s]", deployment.getNodeName()));
LOGGER.warn(" Public ip address will be set to 999.999.999.999");
publicIPAddr = "999.999.999.999";
}
IpAddress ipAddress = new IpAddress(IpAddressType.PUBLIC_IP,
IpVersion.V4,
publicIPAddr);
......
URL url_name = new URL("http://bot.whatismyipaddress.com");
URL url_name = new URL("https://api.ipify.org");
BufferedReader sc = new BufferedReader(new InputStreamReader(url_name.openStream()));
// reads system IPAddress
systemipaddress = sc.readLine().trim();
System.out.println("Public IP Address: " + systemipaddress +"\n");
System.out.println("Public IP Address: " + systemipaddress + "\n");
result = systemipaddress
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment