cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [3/3] git commit: updated refs/heads/affinity_groups to d68856a
Date Thu, 04 Apr 2013 06:24:04 GMT
Added cleanup of affinitygroups when a VM is expunging and when the account is deleted.


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

Branch: refs/heads/affinity_groups
Commit: d68856a2ffbdb41ea1fccddf21f4a1d7251d8114
Parents: f786535
Author: Prachi Damle <prachi@cloud.com>
Authored: Wed Apr 3 16:53:57 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Wed Apr 3 16:53:57 2013 -0700

----------------------------------------------------------------------
 server/src/com/cloud/user/AccountManagerImpl.java  |   11 +++++++++--
 .../affinity/AffinityGroupServiceImpl.java         |    5 ++---
 2 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d68856a2/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 b69f314..d7e27ef 100755
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -42,6 +42,7 @@ import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
 import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
 import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
 import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
@@ -220,6 +221,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager,
M
     @Inject
     private AutoScaleManager _autoscaleMgr;
     @Inject VolumeManager volumeMgr;
+    @Inject
+    private AffinityGroupDao _affinityGroupDao;
 
     private List<UserAuthenticator> _userAuthenticators;
 
@@ -237,11 +240,11 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager,
M
     public List<UserAuthenticator> getUserAuthenticators() {
     	return _userAuthenticators;
     }
-    
+
     public void setUserAuthenticators(List<UserAuthenticator> authenticators) {
     	_userAuthenticators = authenticators;
     }
-    
+
     @Override
     public boolean configure(final String name, final Map<String, Object> params) throws
ConfigurationException {
         _systemAccount = _accountDao.findById(AccountVO.ACCOUNT_ID_SYSTEM);
@@ -606,6 +609,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager,
M
             int numRemoved = _securityGroupDao.removeByAccountId(accountId);
             s_logger.info("deleteAccount: Deleted " + numRemoved + " network groups for account
" + accountId);
 
+            // Cleanup affinity groups
+            int numAGRemoved = _affinityGroupDao.removeByAccountId(accountId);
+            s_logger.info("deleteAccount: Deleted " + numAGRemoved + " affinity groups for
account " + accountId);
+
             // Delete all the networks
             boolean networksDeleted = true;
             s_logger.debug("Deleting networks for account " + account.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d68856a2/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
index e143db4..17f7401 100644
--- a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
+++ b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
@@ -240,6 +240,7 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
     @Override
     public boolean configure(final String name, final Map<String, Object> params) throws
ConfigurationException {
         _name = name;
+        VirtualMachine.State.getStateMachine().registerListener(this);
         return true;
     }
 
@@ -308,9 +309,7 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
                 throw new InvalidParameterValueException("Unable to find affinity group by
id " + affinityGroupId);
             }
         }
-        if (affinityGroupIds != null && !affinityGroupIds.isEmpty()) {
-            _affinityGroupVMMapDao.updateMap(vmId, affinityGroupIds);
-        }
+        _affinityGroupVMMapDao.updateMap(vmId, affinityGroupIds);
         // APIResponseHelper will pull out the updated affinitygroups.
         return vmInstance;
 


Mime
View raw message