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.4 to f7dd172
Date Mon, 23 Jun 2014 18:25:55 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4 0d23ad903 -> f7dd1720c


CLOUDSTACK-6854: Fix inconsistent IPv6 address formats

fc00:0003:1373::0002 should be treated the same as fc00:3:1373::2.
(cherry picked from commit dfe20f34f2e72335586b0e014ba1f91aa4ed473e)


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

Branch: refs/heads/4.4
Commit: f7dd1720cb6217d4425e9a92268f6b716e88a18c
Parents: 0d23ad9
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Fri Jun 20 17:36:49 2014 -0700
Committer: Daan Hoogland <daan@onecht.net>
Committed: Mon Jun 23 20:25:43 2014 +0200

----------------------------------------------------------------------
 .../admin/vlan/CreateVlanIpRangeCmd.java        |  9 +--
 .../command/user/network/CreateNetworkCmd.java  |  9 +--
 .../api/command/user/vm/DeployVMCmd.java        | 59 ++++++++++----------
 utils/src/com/cloud/utils/net/NetUtils.java     | 29 ++++++----
 .../test/com/cloud/utils/net/NetUtilsTest.java  | 23 +++++---
 5 files changed, 71 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f7dd1720/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
index 75edfce..6032625 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.admin.vlan;
 
+import com.cloud.utils.net.NetUtils;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
@@ -166,28 +167,28 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
         if (startIpv6 == null) {
             return null;
         }
-        return startIpv6.toLowerCase();
+        return NetUtils.standardizeIp6Address(startIpv6);
     }
 
     public String getEndIpv6() {
         if (endIpv6 == null) {
             return null;
         }
-        return endIpv6.toLowerCase();
+        return NetUtils.standardizeIp6Address(endIpv6);
     }
 
     public String getIp6Gateway() {
         if (ip6Gateway == null) {
             return null;
         }
-        return ip6Gateway.toLowerCase();
+        return NetUtils.standardizeIp6Address(ip6Gateway);
     }
 
     public String getIp6Cidr() {
         if (ip6Cidr == null) {
             return null;
         }
-        return ip6Cidr.toLowerCase();
+        return NetUtils.standardizeIp6Cidr(ip6Cidr);
     }
 
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f7dd1720/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
index 43c3d1b..364ba3a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.network;
 
+import com.cloud.utils.net.NetUtils;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.acl.RoleType;
@@ -246,28 +247,28 @@ public class CreateNetworkCmd extends BaseCmd {
         if (startIpv6 == null) {
             return null;
         }
-        return startIpv6.toLowerCase();
+        return NetUtils.standardizeIp6Address(startIpv6);
     }
 
     public String getEndIpv6() {
         if (endIpv6 == null) {
             return null;
         }
-        return endIpv6.toLowerCase();
+        return NetUtils.standardizeIp6Address(endIpv6);
     }
 
     public String getIp6Gateway() {
         if (ip6Gateway == null) {
             return null;
         }
-        return ip6Gateway.toLowerCase();
+        return NetUtils.standardizeIp6Address(ip6Gateway);
     }
 
     public String getIp6Cidr() {
         if (ip6Cidr == null) {
             return null;
         }
-        return ip6Cidr.toLowerCase();
+        return NetUtils.standardizeIp6Cidr(ip6Cidr);
     }
 
     public Long getAclId() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f7dd1720/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 43983bd..1beb595 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -16,16 +16,25 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vm;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.DataCenter.NetworkType;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InsufficientServerCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.Network;
+import com.cloud.network.Network.IpAddresses;
+import com.cloud.offering.DiskOffering;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.Account;
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.net.NetUtils;
+import com.cloud.vm.VirtualMachine;
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
 import org.apache.cloudstack.api.ACL;
@@ -48,25 +57,15 @@ import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InsufficientServerCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.Network;
-import com.cloud.network.Network.IpAddresses;
-import com.cloud.offering.DiskOffering;
-import com.cloud.offering.ServiceOffering;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.user.Account;
-import com.cloud.uservm.UserVm;
-import com.cloud.vm.VirtualMachine;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 @APICommand(name = "deployVirtualMachine", description = "Creates and automatically starts
a virtual machine based on a service offering, disk offering, and template.", responseObject
= UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
@@ -353,7 +352,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
                 String requestedIp = ips.get("ip");
                 String requestedIpv6 = ips.get("ipv6");
                 if (requestedIpv6 != null) {
-                    requestedIpv6 = requestedIpv6.toLowerCase();
+                    requestedIpv6 = NetUtils.standardizeIp6Address(requestedIpv6);
                 }
                 IpAddresses addrs = new IpAddresses(requestedIp, requestedIpv6);
                 ipToNetworkMap.put(networkId, addrs);
@@ -367,7 +366,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
         if (ip6Address == null) {
             return null;
         }
-        return ip6Address.toLowerCase();
+        return NetUtils.standardizeIp6Address(ip6Address);
     }
 
     public List<Long> getAffinityGroupIdList() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f7dd1720/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 8e3e916..97a66f1 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -19,6 +19,16 @@
 
 package com.cloud.utils.net;
 
+import com.cloud.utils.IteratorUtil;
+import com.cloud.utils.Pair;
+import com.cloud.utils.script.Script;
+import com.googlecode.ipv6.IPv6Address;
+import com.googlecode.ipv6.IPv6AddressRange;
+import com.googlecode.ipv6.IPv6Network;
+import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.log4j.Logger;
+
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.lang.reflect.Array;
@@ -40,17 +50,6 @@ import java.util.TreeSet;
 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.cloud.utils.IteratorUtil;
-import com.cloud.utils.Pair;
-import com.cloud.utils.script.Script;
-import com.googlecode.ipv6.IPv6Address;
-import com.googlecode.ipv6.IPv6AddressRange;
-import com.googlecode.ipv6.IPv6Network;
-
 public class NetUtils {
     protected final static Logger s_logger = Logger.getLogger(NetUtils.class);
     public final static String HTTP_PORT = "80";
@@ -1372,6 +1371,14 @@ public class NetUtils {
         return resultIp;
     }
 
+    public static String standardizeIp6Address(String ip6Addr) {
+        return IPv6Address.fromString(ip6Addr).toString();
+    }
+
+    public static String standardizeIp6Cidr(String ip6Cidr){
+        return IPv6Network.fromString(ip6Cidr).toString();
+    }
+
     static final String VLAN_PREFIX = "vlan://";
     static final int VLAN_PREFIX_LENGTH = VLAN_PREFIX.length();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f7dd1720/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 3183826..cd5109c 100644
--- a/utils/test/com/cloud/utils/net/NetUtilsTest.java
+++ b/utils/test/com/cloud/utils/net/NetUtilsTest.java
@@ -19,6 +19,14 @@
 
 package com.cloud.utils.net;
 
+import com.googlecode.ipv6.IPv6Address;
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import java.math.BigInteger;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
 import static org.hamcrest.Matchers.anyOf;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.equalTo;
@@ -31,15 +39,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
-import java.math.BigInteger;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.apache.log4j.Logger;
-import org.junit.Test;
-
-import com.googlecode.ipv6.IPv6Address;
-
 public class NetUtilsTest {
 
     private static final Logger s_logger = Logger.getLogger(NetUtilsTest.class);
@@ -199,6 +198,12 @@ public class NetUtilsTest {
     }
 
     @Test
+    public void testStandardizeIp6Address() {
+        assertEquals(NetUtils.standardizeIp6Address("1234:0000:0000:5678:0000:000:ABCD:0001"),
"1234::5678:0:0:abcd:1");
+        assertEquals(NetUtils.standardizeIp6Cidr("1234:0000:0000:5678:0000:000:ABCD:0001/64"),
"1234::5678:0:0:0:0/64");
+    }
+
+    @Test
     public void testGenerateUriForPvlan() {
         assertEquals("pvlan://123-i456", NetUtils.generateUriForPvlan("123", "456").toString());
     }


Mime
View raw message