mirror of https://github.com/apache/cloudstack.git
bug 12635: enable project account when activate the project
status 12635: resolved fixed
This commit is contained in:
parent
bb9886af29
commit
8d27ecf4de
|
|
@ -916,6 +916,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_ACTIVATE, eventDescription = "activating project")
|
||||
@DB
|
||||
public Project activateProject(long projectId) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
|
|
@ -941,9 +942,16 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
throw new InvalidParameterValueException("Can't activate the project in " + currentState + " state");
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
project.setState(Project.State.Active);
|
||||
_projectDao.update(projectId, project);
|
||||
|
||||
_accountMgr.enableAccount(project.getProjectAccountId());
|
||||
|
||||
txn.commit();
|
||||
|
||||
return _projectDao.findById(projectId);
|
||||
}
|
||||
|
||||
|
|
@ -970,7 +978,8 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
|
||||
}
|
||||
|
||||
private boolean suspendProject(ProjectVO project) throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
private boolean suspendProject(ProjectVO project) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
s_logger.debug("Marking project " + project + " with state " + State.Suspended + " as a part of project suspend...");
|
||||
project.setState(State.Suspended);
|
||||
boolean updateResult = _projectDao.update(project.getId(), project);
|
||||
|
|
@ -979,7 +988,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
long projectAccountId = project.getProjectAccountId();
|
||||
if (!_accountMgr.disableAccount(projectAccountId)) {
|
||||
s_logger.warn("Failed to suspend all project's " + project + " resources; the resources will be suspended later by background thread");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CloudRuntimeException("Failed to mark the project " + project + " with state " + State.Suspended);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,5 +88,7 @@ public interface AccountManager extends AccountService {
|
|||
Pair<User, Account> findUserByApiKey(String apiKey);
|
||||
|
||||
boolean lockAccount(long accountId);
|
||||
|
||||
boolean enableAccount(long accountId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -379,6 +379,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
return _userDao.update(Long.valueOf(userId), userForUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableAccount(long accountId) {
|
||||
boolean success = false;
|
||||
AccountVO acctForUpdate = _accountDao.createForUpdate();
|
||||
|
|
|
|||
Loading…
Reference in New Issue