You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ap...@apache.org on 2013/07/25 13:56:58 UTC

[20/50] git commit: updated refs/heads/ldapplugin to 1f64354

CLOUDSTACK-3735. Domain deletion fails even when the networks within the domain have been destroyed.
When a network is destroyed remove the corresponding network entry from domain_network_ref and account_network_ref table


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

Branch: refs/heads/ldapplugin
Commit: b7a483608f6041d681439663a8806c3d02771a48
Parents: 2b9d9cf
Author: Likitha Shetty <li...@citrix.com>
Authored: Wed Jul 24 19:37:16 2013 +0530
Committer: Likitha Shetty <li...@citrix.com>
Committed: Wed Jul 24 20:03:51 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/network/dao/NetworkAccountDao.java |  1 +
 .../cloud/network/dao/NetworkAccountDaoImpl.java | 19 +++++++++++++++++--
 .../com/cloud/network/NetworkManagerImpl.java    | 15 ++++++++++++++-
 3 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7a48360/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java b/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java
index c4435c8..2f5458a 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java
@@ -19,4 +19,5 @@ package com.cloud.network.dao;
 import com.cloud.utils.db.GenericDao;
 
 public interface NetworkAccountDao extends GenericDao<NetworkAccountVO, Long> {
+    NetworkAccountVO getAccountNetworkMapByNetworkId(long networkId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7a48360/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
index 0947905..913d677 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
@@ -18,12 +18,27 @@ package com.cloud.network.dao;
 
 import org.springframework.stereotype.Component;
 
-import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
 
 @Component
 public class NetworkAccountDaoImpl extends GenericDaoBase<NetworkAccountVO, Long> implements NetworkAccountDao {
-    public NetworkAccountDaoImpl() {
+    final SearchBuilder<NetworkAccountVO> AllFieldsSearch;
+
+    protected NetworkAccountDaoImpl() {
         super();
+
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
+        AllFieldsSearch.done();
+    }
+
+    @Override
+    public NetworkAccountVO getAccountNetworkMapByNetworkId(long networkId) {
+        SearchCriteria<NetworkAccountVO> sc = AllFieldsSearch.create();
+        sc.setParameters("networkId", networkId);
+        return findOneBy(sc);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7a48360/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 30c4242..b07f3cf 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -121,8 +121,11 @@ import com.cloud.network.dao.FirewallRulesDao;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.IPAddressVO;
 import com.cloud.network.dao.LoadBalancerDao;
+import com.cloud.network.dao.NetworkAccountDao;
+import com.cloud.network.dao.NetworkAccountVO;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkDomainDao;
+import com.cloud.network.dao.NetworkDomainVO;
 import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.NetworkServiceMapVO;
 import com.cloud.network.dao.NetworkVO;
@@ -262,6 +265,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
     AccountGuestVlanMapDao _accountGuestVlanMapDao;
     @Inject
     DataCenterVnetDao _datacenterVnetDao;
+    @Inject
+    NetworkAccountDao _networkAccountDao;
 
     List<NetworkGuru> _networkGurus;
     public List<NetworkGuru> getNetworkGurus() {
@@ -2892,7 +2897,15 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
                  } catch (NoTransitionException e) {
                      s_logger.debug(e.getMessage());
                  }
-                _networksDao.remove(network.getId());
+                if (_networksDao.remove(network.getId())) {
+                    NetworkDomainVO networkDomain = _networkDomainDao.getDomainNetworkMapByNetworkId(network.getId());
+                    if (networkDomain != null)
+                        _networkDomainDao.remove(networkDomain.getId());
+
+                    NetworkAccountVO networkAccount = _networkAccountDao.getAccountNetworkMapByNetworkId(network.getId());
+                    if (networkAccount != null)
+                        _networkAccountDao.remove(networkAccount.getId());
+                }
 
                 NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
                 boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());