cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: updated refs/heads/4.3 to 9ec137e
Date Tue, 31 Dec 2013 11:18:39 GMT
Updated Branches:
  refs/heads/4.3 e4462f362 -> 9ec137e75


isSameIsolationId

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

Branch: refs/heads/4.3
Commit: 9ec137e75b39a7a462a1160ab3186e4afd156500
Parents: e4462f3
Author: Daan Hoogland <dhoogland@schubergphilis.com>
Authored: Tue Dec 31 12:18:33 2013 +0100
Committer: Daan Hoogland <dhoogland@schubergphilis.com>
Committed: Tue Dec 31 12:18:33 2013 +0100

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java     | 16 ++++++++--------
 utils/src/com/cloud/utils/net/NetUtils.java         |  8 ++++----
 utils/test/com/cloud/utils/net/NetUtilsTest.java    |  8 +++++++-
 3 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ec137e7/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 5781102..dd66e16 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -2471,7 +2471,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager,
Co
         String newVlanNetmask = cmd.getNetmask();
         String vlanId = cmd.getVlan();
         // TODO decide if we should be forgiving or demand a valid and complete URI
-        if(Vlan.UNTAGGED.equalsIgnoreCase(vlanId))
+        if (NetUtils.isSameIsolationId(Vlan.UNTAGGED, vlanId))
             vlanId = null;
         if (!((vlanId == null)
                 || ("".equals(vlanId))
@@ -2660,7 +2660,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager,
Co
                     VlanVO vlan = vlans.get(0);
                     if (vlanId == null) {
                         vlanId = vlan.getVlanTag();
-                    } else if (!vlan.getVlanTag().equals(vlanId)) {
+                    } else if (!NetUtils.isSameIsolationId(vlan.getVlanTag(), vlanId)) {
                         throw new InvalidParameterValueException("there is already one vlan
" + vlan.getVlanTag()
                                 + " on network :" + +network.getId() + ", only one vlan is
allowed on guest network");
                     }
@@ -2907,7 +2907,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager,
Co
             if (vlanId != null) {
                 // if vlan is specified, throw an error if it's not equal to
                 // network's vlanId
-                if (networkVlanId != null && !networkVlanId.equalsIgnoreCase(vlanId))
{
+                if (networkVlanId != null && !NetUtils.isSameIsolationId(networkVlanId,
vlanId)) {
                     throw new InvalidParameterValueException("Vlan doesn't match vlan of
the network");
                 }
             } else {
@@ -2990,16 +2990,16 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager,
Co
                     continue;
                 }
                 String otherCidr = NetUtils.getCidrFromGatewayAndNetmask(otherVlanGateway,
otherVlanNetmask);
-                if( !NetUtils.isNetworksOverlap(newCidr,  otherCidr)) {
+                if (!NetUtils.isNetworksOverlap(newCidr, otherCidr)) {
                     continue;
                 }
                 // from here, subnet overlaps
-                if ( !vlanId.equals(vlan.getVlanTag()) ) {
+                if (!NetUtils.isSameIsolationId(vlanId, vlan.getVlanTag())) {
                     throw new InvalidParameterValueException("The IP range with tag: " +
vlan.getVlanTag()
                             + " in zone " + zone.getName()
                             + " has overlapped with the subnet. Please specify a different
gateway/netmask.");
                 }
-                if ( vlan.getNetworkId() != networkId) {
+                if (vlan.getNetworkId() != networkId) {
                     throw new InvalidParameterValueException("This subnet is overlapped with
subnet in other network " + vlan.getNetworkId()
                             + " in zone " + zone.getName()
                             + " . Please specify a different gateway/netmask.");
@@ -3037,7 +3037,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager,
Co
                 if (vlan.getIp6Gateway() == null) {
                     continue;
                 }
-                if (vlanId.equals(vlan.getVlanTag())) {
+                if (NetUtils.isSameIsolationId(vlanId, vlan.getVlanTag())) {
                     if (NetUtils.isIp6RangeOverlap(ipv6Range, vlan.getIp6Range())) {
                         throw new InvalidParameterValueException("The IPv6 range with tag:
" + vlan.getVlanTag()
                                 + " already has IPs that overlap with the new range. Please
specify a different start IP/end IP.");
@@ -3457,7 +3457,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager,
Co
         List<PortableIpRangeVO> existingPortableIPRanges = _portableIpRangeDao.listByRegionId(_regionDao.getRegionId());
         if (existingPortableIPRanges != null && !existingPortableIPRanges.isEmpty())
{
             for (PortableIpRangeVO portableIpRange : existingPortableIPRanges) {
-                if (portableIpRange.getVlanTag().equalsIgnoreCase(vlanId)) {
+                if (NetUtils.isSameIsolationId(portableIpRange.getVlanTag(), vlanId)) {
                     throw new InvalidParameterValueException("The VLAN tag " + vlanId
                             + " is already being used for portable ip range in this region");
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ec137e7/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 a315b93..1903b29 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -38,6 +38,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.net.util.SubnetUtils;
 import org.apache.log4j.Logger;
 
 import com.googlecode.ipv6.IPv6Address;
@@ -46,7 +47,6 @@ import com.googlecode.ipv6.IPv6Network;
 
 import com.cloud.utils.IteratorUtil;
 import com.cloud.utils.Pair;
-import org.apache.commons.net.util.SubnetUtils;
 import com.cloud.utils.script.Script;
 
 public class NetUtils {
@@ -680,7 +680,7 @@ public class NetUtils {
 
     /**
      * Given a cidr, this method returns an ip address within the range but
-     * is not in the avoid list. 
+     * is not in the avoid list.
      * Note: the gateway address has to be specified in the avoid list
      * 
      * @param cidr ip that the cidr starts with
@@ -1396,7 +1396,7 @@ public class NetUtils {
 
     static final String VLAN_UNTAGGED = "untagged";
 
-    public static boolean sameIsolationId(String one, String other)
+    public static boolean isSameIsolationId(String one, String other)
     {
         // check nulls
         // check empty strings
@@ -1421,7 +1421,7 @@ public class NetUtils {
             other = other.substring(VLAN_PREFIX_LENGTH);
         }
         // check valid uris or numbers
-        if (one.equals(other))
+        if (one.equalsIgnoreCase(other))
         {
             return true;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ec137e7/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 3cfc98f..45a9334 100644
--- a/utils/test/com/cloud/utils/net/NetUtilsTest.java
+++ b/utils/test/com/cloud/utils/net/NetUtilsTest.java
@@ -61,7 +61,7 @@ public class NetUtilsTest extends TestCase {
         assertEquals("This should be -1 because we ran out of ip addresses: " + ip, ip, -1);
     }
 
-    @Test 
+    @Test
     public void testVpnPolicy() {
         assertTrue(NetUtils.isValidS2SVpnPolicy("aes128-sha1"));
         assertTrue(NetUtils.isValidS2SVpnPolicy("3des-sha1"));
@@ -173,4 +173,10 @@ public class NetUtilsTest extends TestCase {
     public void testGetLocalIPString() {
         assertNotNull(NetUtils.getLocalIPString());
     }
+
+    @Test
+    public void testSameIsolationId() {
+        assertTrue(NetUtils.isSameIsolationId("1", "vlan://1"));
+        assertTrue(NetUtils.isSameIsolationId("", null));
+    }
 }


Mime
View raw message