incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pran...@apache.org
Subject git commit: CS-16168:AutoScale- Deletion of Account doesn't delete the AutoScale LB rule
Date Wed, 12 Sep 2012 16:16:42 GMT
Updated Branches:
  refs/heads/autoscale 491e83333 -> e5407525b


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/e5407525
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/e5407525
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/e5407525

Branch: refs/heads/autoscale
Commit: e5407525bc16e8b48359a54feb244894f19529b0
Parents: 491e833
Author: Deepak Garg <deepakgarg.iitg@gmail.com>
Authored: Wed Sep 12 21:46:04 2012 +0530
Committer: Pranav Saxena <pranav.saxena@citrix.com>
Committed: Wed Sep 12 21:46:04 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  |   13 +++++++++-
 10 files changed, 63 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e5407525/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/e5407525/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/e5407525/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/e5407525/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/e5407525/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/e5407525/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/e5407525/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/e5407525/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/e5407525/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 8671151..025e441 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -254,7 +254,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/e5407525/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 0a11dc4..cc02746 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;
@@ -203,6 +204,8 @@ public class AccountManagerImpl implements AccountManager, AccountService,
Manag
     private ProjectAccountDao _projectAccountDao;
     @Inject
     private IPAddressDao _ipAddressDao;
+    private AutoScaleManager _autoscaleMgr;
+    @Inject
 
     private Adapters<UserAuthenticator> _userAuthenticators;
 
@@ -583,11 +586,19 @@ public class AccountManagerImpl implements AccountManager, AccountService,
Manag
             for (IpAddress ip : ipsToRelease) {
                 s_logger.debug("Releasing ip " + ip + " as a part of account id=" + accountId
+ " cleanup");
                 if (!_networkMgr.releasePublicIpAddress(ip.getId(), callerUserId, caller))
{
-                    s_logger.warn("Failed to release ip address " + ip + " as a part of account
id=" + accountId + " clenaup");
+                    s_logger.warn("Failed to release ip address " + ip + " as a part of account
id=" + accountId + " cleanup");
                     accountCleanupNeeded = true;
                 }
             }
 
+            // 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


Mime
View raw message