mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Added cleanup of affinitygroups when a VM is expunging and when the account is deleted.
This commit is contained in:
parent
ec3f844ef1
commit
0b3850c14f
@ -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());
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user