cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sate...@apache.org
Subject [45/50] [abbrv] git commit: updated refs/heads/vmware-storage-motion to 2054164
Date Tue, 14 May 2013 23:15:40 GMT
CLOUDSTACK-2441: Fix deleting private gateways while deleting vpc in case multiple private
gateways


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

Branch: refs/heads/vmware-storage-motion
Commit: c94c71b4ce25bc12a2505547a8fdd79fa574fae3
Parents: 7d38042
Author: Jayapal <jayapalreddy.uradi@citrix.com>
Authored: Tue May 14 16:10:38 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Tue May 14 16:10:38 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/network/vpc/dao/VpcGatewayDao.java   |    5 ++
 .../cloud/network/vpc/dao/VpcGatewayDaoImpl.java   |    9 ++++
 server/src/com/cloud/network/vpc/VpcManager.java   |    2 +
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |   37 +++++++++++----
 server/test/com/cloud/vpc/MockVpcManagerImpl.java  |    5 ++
 5 files changed, 49 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c94c71b4/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
index 8cb5c59..24d9deb 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
@@ -16,13 +16,18 @@
 // under the License.
 package com.cloud.network.vpc.dao;
 
+import com.cloud.network.vpc.VpcGateway;
 import com.cloud.network.vpc.VpcGatewayVO;
 import com.cloud.utils.db.GenericDao;
 
+import java.util.List;
+
 
 public interface VpcGatewayDao extends GenericDao<VpcGatewayVO, Long>{
     VpcGatewayVO getPrivateGatewayForVpc(long vpcId);
     VpcGatewayVO getVpnGatewayForVpc(long vpcId);
 
     Long getNetworkAclIdForPrivateIp(long vpcId, long networkId, String ipaddr);
+
+    List<VpcGatewayVO> listByVpcIdAndType(long vpcId, VpcGateway.Type type);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c94c71b4/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
index b4d403e..6a2f8bd 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
@@ -27,6 +27,8 @@ import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 
+import java.util.List;
+
 @Component
 @Local(value = VpcGatewayDao.class)
 @DB(txn = false)
@@ -76,5 +78,12 @@ public class VpcGatewayDaoImpl extends GenericDaoBase<VpcGatewayVO,
Long> implem
         }
     }
 
+    @Override
+    public List<VpcGatewayVO> listByVpcIdAndType(long vpcId, VpcGateway.Type type)
{
+        SearchCriteria<VpcGatewayVO> sc = AllFieldsSearch.create();
+        sc.setParameters("vpcId", vpcId);
+        sc.setParameters("type", type);
+        return listBy(sc);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c94c71b4/server/src/com/cloud/network/vpc/VpcManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManager.java b/server/src/com/cloud/network/vpc/VpcManager.java
index f3b4bbc..e8db8d3 100644
--- a/server/src/com/cloud/network/vpc/VpcManager.java
+++ b/server/src/com/cloud/network/vpc/VpcManager.java
@@ -165,4 +165,6 @@ public interface VpcManager extends VpcService{
      * @param networkOwner TODO
      */
     void validateNtwkOffForNtwkInVpc(Long networkId, long newNtwkOffId, String newCidr, String
newNetworkDomain, Vpc vpc, String gateway, Account networkOwner);
+
+    List<PrivateGateway> getVpcPrivateGateways(long id);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c94c71b4/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index fb3d41e..f01d81b 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -1236,14 +1236,18 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         }
 
         //4) Delete private gateway
-        PrivateGateway gateway = getVpcPrivateGateway(vpcId);
-        if (gateway != null) {
-            s_logger.debug("Deleting private gateway " + gateway + " as a part of vpc " +
vpcId + " resources cleanup");
-            if (!deleteVpcPrivateGateway(gateway.getId())) {
-                success = false;
-                s_logger.debug("Failed to delete private gateway " + gateway + " as a part
of vpc " + vpcId + " resources cleanup");
-            } else {
-                s_logger.debug("Deleted private gateway " + gateway + " as a part of vpc
" + vpcId + " resources cleanup");
+        List<PrivateGateway> gateways = getVpcPrivateGateways(vpcId);
+        if (gateways != null) {
+            for (PrivateGateway gateway: gateways) {
+                if (gateway != null) {
+                    s_logger.debug("Deleting private gateway " + gateway + " as a part of
vpc " + vpcId + " resources cleanup");
+                    if (!deleteVpcPrivateGateway(gateway.getId())) {
+                        success = false;
+                        s_logger.debug("Failed to delete private gateway " + gateway + "
as a part of vpc " + vpcId + " resources cleanup");
+                    } else {
+                        s_logger.debug("Deleted private gateway " + gateway + " as a part
of vpc " + vpcId + " resources cleanup");
+                    }
+                }
             }
         }
         
@@ -1293,7 +1297,22 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         }  
     }
     
-    
+
+    @Override
+    public List<PrivateGateway> getVpcPrivateGateways(long id) {
+        List<VpcGatewayVO> gateways = _vpcGatewayDao.listByVpcIdAndType(id, VpcGateway.Type.Private);
+
+        if (gateways != null) {
+            List<PrivateGateway> pvtGateway = new ArrayList();
+            for (VpcGatewayVO gateway: gateways) {
+                pvtGateway.add(getPrivateGatewayProfile(gateway));
+            }
+            return pvtGateway;
+        } else {
+            return null;
+        }
+    }
+
     @Override
     public PrivateGateway getVpcPrivateGateway(long id) {
         VpcGateway gateway = _vpcGatewayDao.findById(id);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c94c71b4/server/test/com/cloud/vpc/MockVpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockVpcManagerImpl.java b/server/test/com/cloud/vpc/MockVpcManagerImpl.java
index 1e2cd5f..9812750 100644
--- a/server/test/com/cloud/vpc/MockVpcManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockVpcManagerImpl.java
@@ -378,4 +378,9 @@ public class MockVpcManagerImpl extends ManagerBase implements VpcManager
{
         
     }
 
+    @Override
+    public List<PrivateGateway> getVpcPrivateGateways(long id) {
+        return null;
+    }
+
 }


Mime
View raw message