mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +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() {
|
public static InetAddress[] getAllLocalInetAddresses() {
|
||||||
List<InetAddress> addrList = new ArrayList<InetAddress>();
|
List<InetAddress> addrList = new ArrayList<InetAddress>();
|
||||||
try {
|
try {
|
||||||
@ -848,6 +858,7 @@ public class NetUtils {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
configLog4j();
|
configLog4j();
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
System.out.println("Must specify at least one parameter");
|
System.out.println("Must specify at least one parameter");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user