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-1219, CLOUDSTACK-1220: Fix IPv6 error messages
Date Fri, 15 Feb 2013 00:28:17 GMT
Updated Branches:
  refs/heads/4.1 07ce770e9 -> 5ec29e960


CLOUDSTACK-1219, CLOUDSTACK-1220: Fix IPv6 error messages


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

Branch: refs/heads/4.1
Commit: 5ec29e9608cc6fa9ad28dea3bfd98aa188dfb642
Parents: 07ce770
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Thu Feb 14 16:19:17 2013 -0800
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Thu Feb 14 16:27:53 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkModel.java        |    2 +
 .../com/cloud/network/Ipv6AddressManagerImpl.java  |    4 +-
 server/src/com/cloud/network/NetworkModelImpl.java |   32 +++++++++++++++
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   17 +-------
 .../com/cloud/network/MockNetworkModelImpl.java    |    6 +++
 .../test/com/cloud/vpc/MockNetworkModelImpl.java   |    6 +++
 6 files changed, 50 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5ec29e96/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 783e5cc..9731a61 100644
--- a/api/src/com/cloud/network/NetworkModel.java
+++ b/api/src/com/cloud/network/NetworkModel.java
@@ -255,4 +255,6 @@ public interface NetworkModel {
 	boolean isIP6AddressAvailableInVlan(long vlanId);
 
 	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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5ec29e96/server/src/com/cloud/network/Ipv6AddressManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/Ipv6AddressManagerImpl.java b/server/src/com/cloud/network/Ipv6AddressManagerImpl.java
index ecef5a2..a401f9a 100644
--- a/server/src/com/cloud/network/Ipv6AddressManagerImpl.java
+++ b/server/src/com/cloud/network/Ipv6AddressManagerImpl.java
@@ -80,7 +80,7 @@ public class Ipv6AddressManagerImpl extends ManagerBase implements Ipv6AddressMa
 		}
     	List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId);
     	if (vlans == null) {
-    		s_logger.debug("Cannot find related vlan or too many vlan attached to network " + networkId);
+    		s_logger.debug("Cannot find related vlan attached to network " + networkId);
     		return null;
     	}
     	String ip = null; 
@@ -109,7 +109,7 @@ public class Ipv6AddressManagerImpl extends ManagerBase implements Ipv6AddressMa
     			}
     		}
     		if (ip == null) {
-    			throw new InsufficientAddressCapacityException("Cannot find a usable IP in the network
" + network.getName() + " after network.ipv6.search.retry.max = " + _ipv6RetryMax + " times
retry!",
+    			throw new InsufficientAddressCapacityException("Cannot find a usable IP in the network
" + network.getName() + " after " + _ipv6RetryMax + "(network.ipv6.search.retry.max) times
retry!",
     						DataCenter.class, network.getDataCenterId());
     		}
     	} else {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5ec29e96/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 ca7a900..beebb87 100644
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -1923,4 +1923,36 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
             throw new InvalidParameterValueException("The cidr size of IPv6 network must
be no less than 64 bits!");
         }
     }
+
+    @Override
+    public void checkRequestedIpAddresses(long networkId, String ip4, String ip6) throws
InvalidParameterValueException {
+        if (ip4 != null) {
+            if (!NetUtils.isValidIp(ip4)) {
+                throw new InvalidParameterValueException("Invalid specified IPv4 address
" + ip4);
+            }
+            //Other checks for ipv4 are done in assignPublicIpAddress()
+        }
+        if (ip6 != null) {
+            if (!NetUtils.isValidIpv6(ip6)) {
+                throw new InvalidParameterValueException("Invalid specified IPv6 address
" + ip6);
+            }
+            if (_ipv6Dao.findByNetworkIdAndIp(networkId, ip6) != null) {
+                throw new InvalidParameterValueException("The requested IP is already taken!");
+            }
+            List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId);
+            if (vlans == null) {
+                throw new CloudRuntimeException("Cannot find related vlan attached to network
" + networkId);
+            }
+            Vlan ipVlan = null;
+            for (Vlan vlan : vlans) {
+                if (NetUtils.isIp6InRange(ip6, vlan.getIp6Range())) {
+                    ipVlan = vlan;
+                    break;
+                }
+            }
+            if (ipVlan == null) {
+                throw new InvalidParameterValueException("Requested IPv6 is not in the predefined
range!");
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5ec29e96/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 662dab3..2382b4b 100644
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -3229,7 +3229,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
             if (requestedIpPair == null) {
             	requestedIpPair = new IpAddresses(null, null);
             } else {
-            	checkRequestedIpAddresses(requestedIpPair.getIp4Address(), requestedIpPair.getIp6Address());
+            	_networkModel.checkRequestedIpAddresses(network.getId(), requestedIpPair.getIp4Address(),
requestedIpPair.getIp6Address());
             }
             
             NicProfile profile = new NicProfile(requestedIpPair.getIp4Address(), requestedIpPair.getIp6Address());
@@ -3238,7 +3238,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                 defaultNetworkNumber++;
                 // if user requested specific ip for default network, add it
                 if (defaultIps.getIp4Address() != null || defaultIps.getIp6Address() != null)
{
-                	checkRequestedIpAddresses(defaultIps.getIp4Address(), defaultIps.getIp6Address());
+                	_networkModel.checkRequestedIpAddresses(network.getId(), defaultIps.getIp4Address(),
defaultIps.getIp6Address());
                     profile = new NicProfile(defaultIps.getIp4Address(), defaultIps.getIp6Address());
                 }
 
@@ -3415,19 +3415,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
         return vm;
     }
 
-    private void checkRequestedIpAddresses(String ip4, String ip6) throws InvalidParameterValueException
{
-    	if (ip4 != null) {
-    		if (!NetUtils.isValidIp(ip4)) {
-    			throw new InvalidParameterValueException("Invalid specified IPv4 address " + ip4);
-    		}
-    	}
-    	if (ip6 != null) {
-    		if (!NetUtils.isValidIpv6(ip6)) {
-    			throw new InvalidParameterValueException("Invalid specified IPv6 address " + ip6);
-    		}
-    	}
-	}
-
 	private void validateUserData(String userData) {
         byte[] decodedUserData = null;
         if (userData != null) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5ec29e96/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 a2bef63..d7ffa7d 100644
--- a/server/test/com/cloud/network/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/network/MockNetworkModelImpl.java
@@ -829,4 +829,10 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel
{
 		// TODO Auto-generated method stub
 		
 	}
+
+	@Override
+	public void checkRequestedIpAddresses(long networkId, String ip4, String ip6)
+			throws InvalidParameterValueException {
+		// TODO Auto-generated method stub
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5ec29e96/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 3fad338..5ac8777 100644
--- a/server/test/com/cloud/vpc/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkModelImpl.java
@@ -842,4 +842,10 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel
{
             // TODO Auto-generated method stub
         }
 
+	@Override
+	public void checkRequestedIpAddresses(long networkId, String ip4, String ip6)
+			throws InvalidParameterValueException {
+		// TODO Auto-generated method stub
+	}
+
 }


Mime
View raw message