cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [06/10] git commit: updated refs/heads/vmsync to 3ecc52a
Date Thu, 04 Jul 2013 00:57:39 GMT
fix can't find host ip address on Mac OS


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b59b1b4c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b59b1b4c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b59b1b4c

Branch: refs/heads/vmsync
Commit: b59b1b4c9341eb1a71845eb144426bd1bb7e9cca
Parents: 810c64e
Author: Edison Su <sudison@gmail.com>
Authored: Tue Jul 2 15:19:32 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Jul 3 14:34:37 2013 -0700

----------------------------------------------------------------------
 utils/src/com/cloud/utils/net/NetUtils.java | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b59b1b4c/utils/src/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java
index 6099379..68f4965 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -26,14 +26,7 @@ import java.net.NetworkInterface;
 import java.net.SocketException;
 import java.net.URI;
 import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Formatter;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -46,6 +39,7 @@ import com.googlecode.ipv6.IPv6Network;
 import com.cloud.utils.IteratorUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.script.Script;
+import org.apache.commons.lang.SystemUtils;
 
 public class NetUtils {
     protected final static Logger s_logger = Logger.getLogger(NetUtils.class);
@@ -158,8 +152,10 @@ public class NetUtils {
         return false;
     }
 
+
+
     public static String getDefaultHostIp() {
-        if(isWindows()) {
+        if(SystemUtils.IS_OS_WINDOWS) {
             Pattern pattern = Pattern.compile("\\s*0.0.0.0\\s*0.0.0.0\\s*(\\S*)\\s*(\\S*)\\s*");
             try {
                 Process result = Runtime.getRuntime().exec("route print -4");
@@ -197,6 +193,10 @@ public class NetUtils {
     }
 
     public static String getDefaultEthDevice() {
+        if (SystemUtils.IS_OS_MAC) {
+            String defDev = Script.runSimpleBashScript("/sbin/route -n get default | grep
interface | awk '{print $2}'");
+            return defDev;
+        }
         String defaultRoute = Script.runSimpleBashScript("/sbin/route | grep default");
 
         if (defaultRoute == null) {
@@ -212,6 +212,8 @@ public class NetUtils {
         return defaultRouteList[7];
     }
 
+
+
     public static InetAddress getFirstNonLoopbackLocalInetAddress() {
         InetAddress[] addrs = getAllLocalInetAddresses();
         if (addrs != null) {


Mime
View raw message