mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Add a DNS name resolution helper
This commit is contained in:
parent
05be5acfda
commit
aadeceaf78
@ -81,6 +81,16 @@ public class NetUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String resolveToIp(String host) {
|
||||
try {
|
||||
InetAddress addr = InetAddress.getByName(host);
|
||||
return ipFromInetAddress(addr);
|
||||
} catch (UnknownHostException e) {
|
||||
s_logger.warn("Unable to resolve " + host + " to IP due to UnknownHostException");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static InetAddress[] getAllLocalInetAddresses() {
|
||||
List<InetAddress> addrList = new ArrayList<InetAddress>();
|
||||
try {
|
||||
@ -848,6 +858,7 @@ public class NetUtils {
|
||||
|
||||
public static void main(String[] args) {
|
||||
configLog4j();
|
||||
|
||||
if (args.length == 0) {
|
||||
System.out.println("Must specify at least one parameter");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user