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/master - CLOUDSTACK-1218: Use the first IP in the first vlan range for VR in shared network
Date Thu, 14 Mar 2013 20:23:14 GMT
Updated Branches:
  refs/heads/master 0bf5f5ede -> 98291d043


CLOUDSTACK-1218: Use the first IP in the first vlan range for VR in shared network


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

Branch: refs/heads/master
Commit: 98291d043de47ef6c999907aca3d1d31464f6a87
Parents: 0bf5f5e
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Wed Mar 13 17:02:19 2013 -0700
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Thu Mar 14 13:13:31 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkModel.java        |    2 +
 server/src/com/cloud/network/NetworkModelImpl.java |   17 +++++++
 .../router/VirtualNetworkApplianceManagerImpl.java |   35 ++++++++++----
 .../com/cloud/network/MockNetworkModelImpl.java    |    6 +++
 .../test/com/cloud/vpc/MockNetworkModelImpl.java   |    6 +++
 5 files changed, 56 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/98291d04/api/src/com/cloud/network/NetworkModel.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkModel.java b/api/src/com/cloud/network/NetworkModel.java
index 9731a61..60e1f7f 100644
--- a/api/src/com/cloud/network/NetworkModel.java
+++ b/api/src/com/cloud/network/NetworkModel.java
@@ -257,4 +257,6 @@ public interface NetworkModel {
 	void checkIp6Parameters(String startIPv6, String endIPv6, String ip6Gateway, String ip6Cidr)
throws InvalidParameterValueException;
 
 	void checkRequestedIpAddresses(long networkId, String ip4, String ip6) throws InvalidParameterValueException;
+
+	String getStartIpv6Address(long id);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/98291d04/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 46790b3..52089df 100644
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -1972,4 +1972,21 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
             }
         }
     }
+
+	@Override
+	public String getStartIpv6Address(long networkId) {
+    	List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId);
+    	if (vlans == null) {
+    		return null;
+    	}
+    	String startIpv6 = null;
+    	// Get the start ip of first create vlan(not the lowest, because if you add a lower
vlan, lowest vlan would change)
+    	for (Vlan vlan : vlans) {
+    		if (vlan.getIp6Range() != null) {
+    			startIpv6 = vlan.getIp6Range().split("-")[0];
+    			break;
+    		}
+    	}
+		return startIpv6;
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/98291d04/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 3cbd51d..ce65586 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -162,6 +162,7 @@ import com.cloud.network.dao.Site2SiteCustomerGatewayDao;
 import com.cloud.network.dao.Site2SiteVpnConnectionDao;
 import com.cloud.network.dao.Site2SiteVpnConnectionVO;
 import com.cloud.network.dao.Site2SiteVpnGatewayDao;
+import com.cloud.network.dao.UserIpv6AddressDao;
 import com.cloud.network.dao.VirtualRouterProviderDao;
 import com.cloud.network.dao.VpnUserDao;
 import com.cloud.network.lb.LoadBalancingRule;
@@ -340,6 +341,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements
V
     Site2SiteVpnConnectionDao _s2sVpnConnectionDao;
     @Inject
     Site2SiteVpnManager _s2sVpnMgr;
+    @Inject
+    UserIpv6AddressDao _ipv6Dao;
 
     
     int _routerRamSize;
@@ -1696,18 +1699,30 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
         boolean hasGuestNetwork = false;
         if (guestNetwork != null) {
             s_logger.debug("Adding nic for Virtual Router in Guest network " + guestNetwork);
-            String defaultNetworkStartIp = null;
-            if (guestNetwork.getCidr() != null && !setupPublicNetwork) {
-                String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
-                if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(),
startIp).getAllocatedTime() == null) {
-                    defaultNetworkStartIp = startIp;
-                } else if (s_logger.isDebugEnabled()){
-                    s_logger.debug("First ip " + startIp + " in network id=" + guestNetwork.getId()
+ 
-                            " is already allocated, can't use it for domain router; will
get random ip address from the range");
-                }
+            String defaultNetworkStartIp = null, defaultNetworkStartIpv6 = null;
+            if (!setupPublicNetwork) {
+            	if (guestNetwork.getCidr() != null) {
+            		String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
+            		if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(),
startIp).getAllocatedTime() == null) {
+            			defaultNetworkStartIp = startIp;
+            		} else if (s_logger.isDebugEnabled()){
+            			s_logger.debug("First ip " + startIp + " in network id=" + guestNetwork.getId()
+ 
+            					" is already allocated, can't use it for domain router; will get random
ip address from the range");
+            		}
+            	}
+            	
+            	if (guestNetwork.getIp6Cidr() != null) {
+            		String startIpv6 = _networkModel.getStartIpv6Address(guestNetwork.getId());
+            		if (startIpv6 != null && _ipv6Dao.findByNetworkIdAndIp(guestNetwork.getId(),
startIpv6) == null) {
+            			defaultNetworkStartIpv6 = startIpv6;
+            		} else if (s_logger.isDebugEnabled()){
+            			s_logger.debug("First ipv6 " + startIpv6 + " in network id=" + guestNetwork.getId()
+ 
+            					" is already allocated, can't use it for domain router; will get random
ipv6 address from the range");
+            		}
+            	}
             }
 
-            NicProfile gatewayNic = new NicProfile(defaultNetworkStartIp, null);
+            NicProfile gatewayNic = new NicProfile(defaultNetworkStartIp, defaultNetworkStartIpv6);
             if (setupPublicNetwork) {
                 if (isRedundant) {
                     gatewayNic.setIp4Address(_networkMgr.acquireGuestIpAddress(guestNetwork,
null));

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/98291d04/server/test/com/cloud/network/MockNetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkModelImpl.java b/server/test/com/cloud/network/MockNetworkModelImpl.java
index d7ffa7d..83dddf4 100644
--- a/server/test/com/cloud/network/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/network/MockNetworkModelImpl.java
@@ -835,4 +835,10 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel
{
 			throws InvalidParameterValueException {
 		// TODO Auto-generated method stub
 	}
+
+	@Override
+	public String getStartIpv6Address(long id) {
+		// TODO Auto-generated method stub
+		return null;
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/98291d04/server/test/com/cloud/vpc/MockNetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkModelImpl.java b/server/test/com/cloud/vpc/MockNetworkModelImpl.java
index 5ac8777..7f1f945 100644
--- a/server/test/com/cloud/vpc/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkModelImpl.java
@@ -848,4 +848,10 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel
{
 		// TODO Auto-generated method stub
 	}
 
+	@Override
+	public String getStartIpv6Address(long id) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
 }


Mime
View raw message