|
39 | 39 | import com.cloud.configuration.Resource.ResourceType; |
40 | 40 | import com.cloud.configuration.ResourceCount; |
41 | 41 | import com.cloud.configuration.ResourceCountVO; |
| 42 | +import com.cloud.configuration.ResourceLimit; |
42 | 43 | import com.cloud.configuration.ResourceLimitVO; |
43 | 44 | import com.cloud.configuration.dao.ConfigurationDao; |
44 | 45 | import com.cloud.configuration.dao.ResourceCountDao; |
@@ -205,6 +206,12 @@ public void decrementResourceCount(long accountId, ResourceType type, Long... de |
205 | 206 | public long findCorrectResourceLimitForAccount(Account account, ResourceType type) { |
206 | 207 |
|
207 | 208 | long max = Resource.RESOURCE_UNLIMITED; // if resource limit is not found, then we treat it as unlimited |
| 209 | + |
| 210 | + //no limits for Admin accounts |
| 211 | + if (_accountMgr.isAdmin(account.getType())) { |
| 212 | + return max; |
| 213 | + } |
| 214 | + |
208 | 215 | ResourceLimitVO limit = _resourceLimitDao.findByOwnerIdAndType(account.getId(), ResourceOwnerType.Account, type); |
209 | 216 |
|
210 | 217 | // Check if limit is configured for account |
@@ -496,9 +503,14 @@ public ResourceLimitVO updateResourceLimit(Long accountId, Long domainId, Intege |
496 | 503 |
|
497 | 504 | if (accountId != null) { |
498 | 505 | Account account = _entityMgr.findById(Account.class, accountId); |
499 | | - if (account.getType() == Account.ACCOUNT_ID_SYSTEM) { |
| 506 | + if (account.getId() == Account.ACCOUNT_ID_SYSTEM) { |
500 | 507 | throw new InvalidParameterValueException("Can't update system account"); |
501 | 508 | } |
| 509 | + |
| 510 | + //only Unlimited value is accepted if account is Admin |
| 511 | + if (_accountMgr.isAdmin(account.getType()) && max.shortValue() != ResourceLimit.RESOURCE_UNLIMITED) { |
| 512 | + throw new InvalidParameterValueException("Only " + ResourceLimit.RESOURCE_UNLIMITED + " limit is supported for Admin accounts"); |
| 513 | + } |
502 | 514 |
|
503 | 515 | if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) { |
504 | 516 | _accountMgr.checkAccess(caller, AccessType.ModifyProject, true, account); |
|
0 commit comments