mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-20 20:43:43 +01:00
bug 14033: root/domain admin limits are always Unlimited. Return it as Unlimited in listResourceLimit response
status 14033: resolved fixed
This commit is contained in:
parent
25676aa3c6
commit
e992a25e1a
@ -39,6 +39,7 @@ import com.cloud.configuration.Resource.ResourceOwnerType;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.configuration.ResourceCount;
|
||||
import com.cloud.configuration.ResourceCountVO;
|
||||
import com.cloud.configuration.ResourceLimit;
|
||||
import com.cloud.configuration.ResourceLimitVO;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.configuration.dao.ResourceCountDao;
|
||||
@ -205,6 +206,12 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager {
|
||||
public long findCorrectResourceLimitForAccount(Account account, ResourceType type) {
|
||||
|
||||
long max = Resource.RESOURCE_UNLIMITED; // if resource limit is not found, then we treat it as unlimited
|
||||
|
||||
//no limits for Admin accounts
|
||||
if (_accountMgr.isAdmin(account.getType())) {
|
||||
return max;
|
||||
}
|
||||
|
||||
ResourceLimitVO limit = _resourceLimitDao.findByOwnerIdAndType(account.getId(), ResourceOwnerType.Account, type);
|
||||
|
||||
// Check if limit is configured for account
|
||||
@ -496,9 +503,14 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager {
|
||||
|
||||
if (accountId != null) {
|
||||
Account account = _entityMgr.findById(Account.class, accountId);
|
||||
if (account.getType() == Account.ACCOUNT_ID_SYSTEM) {
|
||||
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
|
||||
throw new InvalidParameterValueException("Can't update system account");
|
||||
}
|
||||
|
||||
//only Unlimited value is accepted if account is Admin
|
||||
if (_accountMgr.isAdmin(account.getType()) && max.shortValue() != ResourceLimit.RESOURCE_UNLIMITED) {
|
||||
throw new InvalidParameterValueException("Only " + ResourceLimit.RESOURCE_UNLIMITED + " limit is supported for Admin accounts");
|
||||
}
|
||||
|
||||
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
_accountMgr.checkAccess(caller, AccessType.ModifyProject, true, account);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user