cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject git commit: updated refs/heads/master-6-17-stable to 0d84197
Date Mon, 24 Jun 2013 12:28:59 GMT
Updated Branches:
  refs/heads/master-6-17-stable 492626220 -> 0d841971b


CLOUDSTACK-3124: Deletion of ACL associated with a tier/ pvt gateway should not be allowed.
Check for associated tiers/gateways before deletion


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

Branch: refs/heads/master-6-17-stable
Commit: 0d841971b52a647a30a6ae641eda908425a6a2bb
Parents: 4926262
Author: Kishan Kavala <kishan@cloud.com>
Authored: Mon Jun 24 17:53:15 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Mon Jun 24 17:53:15 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/network/vpc/dao/VpcGatewayDao.java    |  2 ++
 .../com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java    |  8 ++++++++
 .../com/cloud/network/vpc/NetworkACLManagerImpl.java    | 12 ++++++++++++
 3 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d841971/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 24d9deb..42144b6 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
@@ -30,4 +30,6 @@ public interface VpcGatewayDao extends GenericDao<VpcGatewayVO, Long>{
     Long getNetworkAclIdForPrivateIp(long vpcId, long networkId, String ipaddr);
 
     List<VpcGatewayVO> listByVpcIdAndType(long vpcId, VpcGateway.Type type);
+
+    List<VpcGatewayVO> listByAclIdAndType(long aclId, VpcGateway.Type type);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d841971/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 6a2f8bd..a8cb2b3 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
@@ -41,6 +41,7 @@ public class VpcGatewayDaoImpl extends GenericDaoBase<VpcGatewayVO, Long>
implem
         AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), SearchCriteria.Op.EQ);
         AllFieldsSearch.and("networkid", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
         AllFieldsSearch.and("ipaddress", AllFieldsSearch.entity().getIp4Address(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("aclId", AllFieldsSearch.entity().getNetworkACLId(), SearchCriteria.Op.EQ);
         AllFieldsSearch.done();
     }
 
@@ -86,4 +87,11 @@ public class VpcGatewayDaoImpl extends GenericDaoBase<VpcGatewayVO,
Long> implem
         return listBy(sc);
     }
 
+    @Override
+    public List<VpcGatewayVO> listByAclIdAndType(long aclId, VpcGateway.Type type)
{
+        SearchCriteria<VpcGatewayVO> sc = AllFieldsSearch.create();
+        sc.setParameters("aclId", aclId);
+        sc.setParameters("type", type);
+        return listBy(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d841971/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
index c2d092a..4881b73 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
@@ -122,6 +122,18 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
         if(aclItems.size() > 0){
             throw new CloudRuntimeException("ACL is not empty. Cannot delete network ACL:
"+acl.getUuid());
         }
+
+        List<NetworkVO> networks = _networkDao.listByAclId(acl.getId());
+        if(networks != null && networks.size() > 0){
+            throw new CloudRuntimeException("ACL is still associated with "+networks.size()+"
tier(s). Cannot delete network ACL: "+acl.getUuid());
+        }
+
+        List<VpcGatewayVO> pvtGateways = _vpcGatewayDao.listByAclIdAndType(acl.getId(),
VpcGateway.Type.Private);
+
+        if(pvtGateways != null && pvtGateways.size() > 0){
+            throw new CloudRuntimeException("ACL is still associated with "+pvtGateways.size()+"
private gateway(s). Cannot delete network ACL: "+acl.getUuid());
+        }
+
         return _networkACLDao.remove(acl.getId());
     }
 


Mime
View raw message