incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yas...@apache.org
Subject git commit: refs/heads/4.1 - CLOUDSTACK-1303: Fix NPE when extend vlan with ipv4 only
Date Fri, 22 Feb 2013 00:45:25 GMT
Updated Branches:
  refs/heads/4.1 172de3034 -> 1f64917fc


CLOUDSTACK-1303: Fix NPE when extend vlan with ipv4 only


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

Branch: refs/heads/4.1
Commit: 1f64917fcc21ab1a670d18b319d68e57fee71ce1
Parents: 172de30
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Thu Feb 21 16:38:39 2013 -0800
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Thu Feb 21 16:45:15 2013 -0800

----------------------------------------------------------------------
 server/src/com/cloud/network/NetworkModelImpl.java |    3 +++
 utils/src/com/cloud/utils/net/NetUtils.java        |    6 ++++++
 utils/test/com/cloud/utils/net/NetUtilsTest.java   |    5 +++++
 3 files changed, 14 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f64917f/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index ebe5aa4..7b3717a 100644
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -568,6 +568,9 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
     @Override
     public boolean isIP6AddressAvailableInVlan(long vlanId) {
     	VlanVO vlan = _vlanDao.findById(vlanId);
+    	if (vlan.getIp6Range() == null) {
+    		return false;
+    	}
     	long existedCount = _ipv6Dao.countExistedIpsInVlan(vlanId);
     	BigInteger existedInt = BigInteger.valueOf(existedCount);
     	BigInteger rangeInt = NetUtils.countIp6InRange(vlan.getIp6Range());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f64917f/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 f6b62de..dd40a33 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -1192,6 +1192,9 @@ public class NetUtils {
 	
 	// Can cover 127 bits
 	public static BigInteger countIp6InRange(String ip6Range) {
+		if (ip6Range == null) {
+			return null;
+		}
     	String[] ips = ip6Range.split("-");
     	String startIp = ips[0];
     	String endIp = ips[0];
@@ -1214,6 +1217,9 @@ public class NetUtils {
 	}
 
 	public static boolean isIp6InRange(String ip6, String ip6Range) {
+		if (ip6Range == null) {
+			return false;
+		}
     	String[] ips = ip6Range.split("-");
     	String startIp = ips[0];
     	String endIp = null;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f64917f/utils/test/com/cloud/utils/net/NetUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/net/NetUtilsTest.java b/utils/test/com/cloud/utils/net/NetUtilsTest.java
index 09c6f60..28bd71f 100644
--- a/utils/test/com/cloud/utils/net/NetUtilsTest.java
+++ b/utils/test/com/cloud/utils/net/NetUtilsTest.java
@@ -122,5 +122,10 @@ public class NetUtilsTest extends TestCase {
     	assertTrue(NetUtils.isIp6InNetwork("1234:5678::1", "1234:5678::/64"));
     	assertTrue(NetUtils.isIp6InNetwork("1234:5678::ffff:ffff:ffff:ffff", "1234:5678::/64"));
     	assertTrue(NetUtils.isIp6InNetwork("1234:5678::", "1234:5678::/64"));
+    	//Test isIp6InRange
+    	assertTrue(NetUtils.isIp6InRange("1234:5678:abcd::1", "1234:5678:abcd::1-1234:5678:abcd::1"));
+    	assertFalse(NetUtils.isIp6InRange("1234:5678:abcd::1", "1234:5678:abcd::2-1234:5678:abcd::1"));
+    	assertFalse(NetUtils.isIp6InRange("1234:5678:abcd::1", null));
+    	assertTrue(NetUtils.isIp6InRange("1234:5678:abcd::1", "1234:5678::1-1234:5679::1"));
     }
 }


Mime
View raw message