cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [30/47] git commit: updated refs/heads/internallb to 3795048
Date Thu, 11 Apr 2013 21:22:53 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/0b3850c1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0b3850c1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0b3850c1

Branch: refs/heads/internallb
Commit: 0b3850c14f9f3420d92bf6eb3477959b8f28e4ad
Parents: ec3f844
Author: Prachi Damle <prachi@cloud.com>
Authored: Wed Apr 3 16:53:57 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Apr 11 13:23:18 2013 -0700

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0b3850c1/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 bc93df8..fe714c5 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;
     List<UserAuthenticator> _userPasswordEncoders;
@@ -238,7 +241,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager,
M
     public List<UserAuthenticator> getUserAuthenticators() {
     	return _userAuthenticators;
     }
-    
+
     public void setUserAuthenticators(List<UserAuthenticator> authenticators) {
     	_userAuthenticators = authenticators;
     }
@@ -623,6 +626,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/0b3850c1/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