cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [12/18] git commit: updated refs/heads/object_store to c476d78
Date Thu, 16 May 2013 02:42:25 GMT
CLOUDSTACK-2369 fixed adding same private gw twice


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

Branch: refs/heads/object_store
Commit: 85789534f016c0ae5e5a4fe19c18938819d96e99
Parents: 1f5ae4b
Author: Jayapal <jayapalreddy.uradi@citrix.com>
Authored: Wed May 15 15:40:23 2013 +0530
Committer: Edison Su <sudison@gmail.com>
Committed: Wed May 15 19:41:49 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/network/vpc/dao/PrivateIpDao.java    |    3 ++-
 .../cloud/network/vpc/dao/PrivateIpDaoImpl.java    |   11 ++++++++++-
 .../src/com/cloud/network/NetworkServiceImpl.java  |    4 +++-
 3 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85789534/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDao.java b/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDao.java
index 02df92e..ff8c26a 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDao.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDao.java
@@ -70,6 +70,7 @@ public interface PrivateIpDao extends GenericDao<PrivateIpVO, Long>{
      */
     PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address);
 
-    
 
+
+    PrivateIpVO findByIpAndSourceNetworkIdAndVpcId(long networkId, String ip4Address, long
vpcId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85789534/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java b/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java
index ecab3bb..fe435c0 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java
@@ -114,7 +114,16 @@ public class PrivateIpDaoImpl extends GenericDaoBase<PrivateIpVO,
Long> implemen
         sc.setParameters("networkId", networkId);
         return findOneBy(sc);
     }
-    
+
+    @Override
+    public PrivateIpVO findByIpAndSourceNetworkIdAndVpcId(long networkId, String ip4Address,
long vpcId) {
+        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("ip", ip4Address);
+        sc.setParameters("networkId", networkId);
+        sc.setParameters("vpcId", vpcId);
+        return findOneBy(sc);
+    }
+
     @Override
     public PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address) {
         SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85789534/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index f3ec253..d3ef320 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -3813,10 +3813,12 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
             s_logger.debug("Created private network " + privateNetwork);
         } else {
             s_logger.debug("Private network already exists: " + privateNetwork);
+            throw new InvalidParameterValueException("Private network for the vlan: " + vlan
+ " and cidr  "+ cidr +"  already exists " +
+                    " in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());
         }
 
         //add entry to private_ip_address table
-        PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkId(privateNetwork.getId(),
startIp);
+        PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(),
startIp, vpcId);
         if (privateIp != null) {
             throw new InvalidParameterValueException("Private ip address " + startIp + "
already used for private gateway" +
                     " in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());


Mime
View raw message