cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yas...@apache.org
Subject [1/2] git commit: refs/heads/network-refactor - CLOUDSTACK-1218: Use the first IP in the first vlan range for VR in shared network
Date Thu, 14 Mar 2013 22:36:15 GMT
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/143b7bc0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/143b7bc0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/143b7bc0

Branch: refs/heads/network-refactor
Commit: 143b7bc0d807eaecd2e709cbafca2bc7a1c8ed17
Parents: 3b9901d
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Thu Mar 14 15:34:45 2013 -0700
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Thu Mar 14 15:34:45 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkModel.java        |    4 +-
 server/src/com/cloud/network/NetworkModelImpl.java |   18 +++++++-
 .../router/VirtualNetworkApplianceManagerImpl.java |   35 ++++++++++----
 .../com/cloud/network/MockNetworkModelImpl.java    |    6 +++
 4 files changed, 51 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/143b7bc0/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 efc22b4..28d71b1 100644
--- a/api/src/com/cloud/network/NetworkModel.java
+++ b/api/src/com/cloud/network/NetworkModel.java
@@ -255,4 +255,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;
-}
\ No newline at end of file
+
+	String getStartIpv6Address(long id);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/143b7bc0/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 f34f906..403b316 100644
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -1940,4 +1940,20 @@ public class NetworkModelImpl  implements NetworkModel, Manager{
     	}
 	}
 
-}
\ No newline at end of file
+	@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/143b7bc0/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 fb2e2bc..c9ffc35 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -155,6 +155,7 @@ import com.cloud.network.dao.RemoteAccessVpnDao;
 import com.cloud.network.dao.Site2SiteCustomerGatewayDao;
 import com.cloud.network.dao.Site2SiteVpnConnectionDao;
 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;
@@ -329,6 +330,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
     Site2SiteVpnConnectionDao _s2sVpnConnectionDao;
     @Inject
     Site2SiteVpnManager _s2sVpnMgr;
+    @Inject
+    UserIpv6AddressDao _ipv6Dao;
     
     int _routerRamSize;
     int _routerCpuMHz;
@@ -1596,18 +1599,30 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         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/143b7bc0/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 cc83b65..05929e3 100644
--- a/server/test/com/cloud/network/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/network/MockNetworkModelImpl.java
@@ -823,4 +823,10 @@ public class MockNetworkModelImpl implements NetworkModel, Manager {
 			throws InvalidParameterValueException {
 		// TODO Auto-generated method stub
 	}
+
+	@Override
+	public String getStartIpv6Address(long id) {
+		// TODO Auto-generated method stub
+		return null;
+	}
 }


Mime
View raw message