quota: don't lock account, only unlock with adding credits

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2015-07-29 11:14:36 +05:30
parent e4125a2999
commit 70aada690b
1 changed files with 6 additions and 16 deletions

View File

@ -282,22 +282,12 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
TransactionLegacy.open(TransactionLegacy.CLOUD_DB).close();
final AccountVO account = _accountDao.findById(accountId);
final boolean lockAccountEnforcement = QuotaConfig.QuotaEnableEnforcement.value().equalsIgnoreCase("true");
if (lockAccountEnforcement) {
if (_quotaBalanceDao.lastQuotaBalance(accountId, domainId, new Date()).compareTo(new BigDecimal(0)) >= 0) {
if (account.getState() == Account.State.locked) {
try {
_regionMgr.enableAccount(account.getAccountName(), domainId, accountId);
} catch (Exception e) {
s_logger.error(String.format("Unable to unlock account %s after getting enough quota credits", account.getAccountName()));
}
}
} else {
if (account.getState() == Account.State.enabled) {
try {
_regionMgr.disableAccount(account.getAccountName(), domainId, accountId, true);
} catch (Exception e) {
s_logger.error(String.format("Unable to lock account %s due to low balance", account.getAccountName()));
}
if (lockAccountEnforcement && (_quotaBalanceDao.lastQuotaBalance(accountId, domainId, new Date()).compareTo(new BigDecimal(0)) >= 0)) {
if (account.getState() == Account.State.locked) {
try {
_regionMgr.enableAccount(account.getAccountName(), domainId, accountId);
} catch (Exception e) {
s_logger.error(String.format("Unable to unlock account %s after getting enough quota credits", account.getAccountName()));
}
}
}