incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pran...@apache.org
Subject [16/50] git commit: CS-16168:AutoScale- Deletion of Account doesn't delete the AutoScale LB rule
Date Fri, 16 Nov 2012 10:00:31 GMT
CS-16168:AutoScale- Deletion of Account doesn't delete the AutoScale LB rule


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

Branch: refs/heads/master
Commit: d2155890cc87af636c69681a559d72793365740c
Parents: 58db4d0
Author: Deepak Garg <deepakgarg.iitg@gmail.com>
Authored: Wed Sep 12 21:46:04 2012 +0530
Committer: Vijay Venkatachalam <vijay.venkatachalam@citrix.com>
Committed: Fri Nov 16 10:56:57 2012 +0530

----------------------------------------------------------------------
 .../src/com/cloud/network/as/AutoScaleManager.java |    2 +
 .../com/cloud/network/as/AutoScaleManagerImpl.java |   20 +++++++++++++-
 .../cloud/network/as/dao/AutoScalePolicyDao.java   |    1 +
 .../network/as/dao/AutoScalePolicyDaoImpl.java     |    9 ++++++
 .../network/as/dao/AutoScaleVmProfileDao.java      |    2 +
 .../network/as/dao/AutoScaleVmProfileDaoImpl.java  |    9 ++++++
 .../src/com/cloud/network/as/dao/ConditionDao.java |    1 +
 .../com/cloud/network/as/dao/ConditionDaoImpl.java |    9 ++++++-
 .../network/lb/LoadBalancingRulesManagerImpl.java  |    2 +-
 server/src/com/cloud/user/AccountManagerImpl.java  |   11 ++++++++
 10 files changed, 62 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/as/AutoScaleManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/AutoScaleManager.java b/server/src/com/cloud/network/as/AutoScaleManager.java
index 7ea7807..ac822dc 100644
--- a/server/src/com/cloud/network/as/AutoScaleManager.java
+++ b/server/src/com/cloud/network/as/AutoScaleManager.java
@@ -17,4 +17,6 @@
 package com.cloud.network.as;
 
 public interface AutoScaleManager extends AutoScaleService {
+
+    void cleanUpAutoScaleResources(Long accountId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
index b3c997a..ab8c452 100644
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@ -94,8 +94,8 @@ import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.net.NetUtils;
 
-@Local(value = { AutoScaleService.class })
-public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
+@Local(value = { AutoScaleService.class, AutoScaleManager.class })
+public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleService,
Manager {
     private static final Logger s_logger = Logger.getLogger(AutoScaleManagerImpl.class);
 
     String _name;
@@ -1129,4 +1129,20 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService,
Manager {
         return success;
     }
 
+    public void cleanUpAutoScaleResources(Long accountId) {
+        // cleans Autoscale VmProfiles, AutoScale Policies and Conditions belonging to an
account
+        int count = 0;
+        count = _autoScaleVmProfileDao.removeByAccountId(accountId);
+        if (count > 0) {
+            s_logger.debug("Deleted " + count + " AutoScale Vm Profile for account Id: "
+ accountId);
+        }
+        count = _autoScalePolicyDao.removeByAccountId(accountId);
+        if (count > 0) {
+            s_logger.debug("Deleted " + count + " AutoScale Policies for account Id: " +
accountId);
+        }
+        count = _conditionDao.removeByAccountId(accountId);
+        if (count > 0) {
+            s_logger.debug("Deleted " + count + " Conditions for account Id: " + accountId);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/as/dao/AutoScalePolicyDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/dao/AutoScalePolicyDao.java b/server/src/com/cloud/network/as/dao/AutoScalePolicyDao.java
index 8edfa94..51b2a94 100644
--- a/server/src/com/cloud/network/as/dao/AutoScalePolicyDao.java
+++ b/server/src/com/cloud/network/as/dao/AutoScalePolicyDao.java
@@ -20,4 +20,5 @@ import com.cloud.network.as.AutoScalePolicyVO;
 import com.cloud.utils.db.GenericDao;
 
 public interface AutoScalePolicyDao extends GenericDao<AutoScalePolicyVO, Long> {
+    int removeByAccountId(long accountId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java b/server/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java
index 5dfe080..f8f5491 100644
--- a/server/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java
+++ b/server/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java
@@ -20,7 +20,16 @@ import javax.ejb.Local;
 
 import com.cloud.network.as.AutoScalePolicyVO;
 import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
 
 @Local(value = { AutoScalePolicyDao.class })
 public class AutoScalePolicyDaoImpl extends GenericDaoBase<AutoScalePolicyVO, Long>
 implements AutoScalePolicyDao {
+
+    public int removeByAccountId(long accountId) {
+        SearchCriteria<AutoScalePolicyVO> sc = createSearchCriteria();
+
+        sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
+
+        return remove(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java b/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java
index 0803571..d97e848 100644
--- a/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java
+++ b/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java
@@ -20,4 +20,6 @@ import com.cloud.network.as.AutoScaleVmProfileVO;
 import com.cloud.utils.db.GenericDao;
 
 public interface AutoScaleVmProfileDao extends GenericDao<AutoScaleVmProfileVO, Long>
{
+
+    int removeByAccountId(long accountId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java b/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java
index 12392c3..d2b162b 100644
--- a/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java
+++ b/server/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java
@@ -20,7 +20,16 @@ import javax.ejb.Local;
 
 import com.cloud.network.as.AutoScaleVmProfileVO;
 import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
 
 @Local(value = { AutoScaleVmProfileDao.class })
 public class AutoScaleVmProfileDaoImpl extends GenericDaoBase<AutoScaleVmProfileVO, Long>
 implements AutoScaleVmProfileDao {
+
+    @Override
+    public int removeByAccountId(long accountId) {
+        SearchCriteria<AutoScaleVmProfileVO> sc = createSearchCriteria();
+        sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
+
+        return remove(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/as/dao/ConditionDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/dao/ConditionDao.java b/server/src/com/cloud/network/as/dao/ConditionDao.java
index bb0f77f..128920d 100644
--- a/server/src/com/cloud/network/as/dao/ConditionDao.java
+++ b/server/src/com/cloud/network/as/dao/ConditionDao.java
@@ -24,4 +24,5 @@ public interface ConditionDao extends GenericDao<ConditionVO, Long>
{
 
     ConditionVO findByCounterId(long ctrId);
 
+    int removeByAccountId(long accountId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/as/dao/ConditionDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/dao/ConditionDaoImpl.java b/server/src/com/cloud/network/as/dao/ConditionDaoImpl.java
index 338fe19..4f71d45 100644
--- a/server/src/com/cloud/network/as/dao/ConditionDaoImpl.java
+++ b/server/src/com/cloud/network/as/dao/ConditionDaoImpl.java
@@ -38,9 +38,16 @@ public class ConditionDaoImpl extends GenericDaoBase<ConditionVO, Long>
implemen
 
     @Override
     public ConditionVO findByCounterId(long ctrId) {
-        // TODO - may consider indexing counterId field in db-schema
         SearchCriteria<ConditionVO> sc = AllFieldsSearch.create();
         sc.setParameters("counterId", ctrId);
         return findOneBy(sc);
     }
+
+    public int removeByAccountId(long accountId) {
+        SearchCriteria<ConditionVO> sc = createSearchCriteria();
+
+        sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
+
+        return remove(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index c97818c..9944384 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -259,7 +259,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         }
         AutoScaleVmProfile autoScaleVmProfile = _autoScaleVmProfileDao.findById(vmGroup.getProfileId());
         Long autoscaleUserId = autoScaleVmProfile.getAutoScaleUserId();
-        User user = _userDao.findById(autoscaleUserId);
+        User user = _userDao.findByIdIncludingRemoved(autoscaleUserId);
         String apiKey = user.getApiKey();
         String secretKey = user.getSecretKey();
         String csUrl = _configDao.getValue(Config.EndpointeUrl.key());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2155890/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index b19134d..f595478 100755
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -75,6 +75,7 @@ import com.cloud.network.NetworkManager;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.RemoteAccessVpnVO;
 import com.cloud.network.VpnUserVO;
+import com.cloud.network.as.AutoScaleManager;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.RemoteAccessVpnDao;
@@ -214,6 +215,8 @@ public class AccountManagerImpl implements AccountManager, AccountService,
Manag
     private DomainRouterDao _routerDao;
     @Inject
     Site2SiteVpnManager _vpnMgr;
+    @Inject
+    private AutoScaleManager _autoscaleMgr;
 
     private Adapters<UserAuthenticator> _userAuthenticators;
 
@@ -653,6 +656,14 @@ public class AccountManagerImpl implements AccountManager, AccountService,
Manag
                 s_logger.warn("Fail to delete site-to-site VPN customer gateways for account
" + accountId);
             }
 
+            // Delete autoscale resources if any
+            try {
+                _autoscaleMgr.cleanUpAutoScaleResources(accountId);
+            } catch (CloudRuntimeException ex) {
+                s_logger.warn("Failed to cleanup AutoScale resources as a part of account
id=" + accountId + " cleanup due to exception:", ex);
+                accountCleanupNeeded = true;
+            }
+
             // delete account specific Virtual vlans (belong to system Public Network) -
only when networks are cleaned
             // up successfully
             if (networksDeleted) {


Mime
View raw message