mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Bug 11426 - UpdateResourceCount api: don't recalculate the resources for System account
Changes: - Throw error is anyone tries to update the resource limits for ROOT domain using updateResourceLimit API - For ROOT domain always return -1 (infinite) limit - DB upgrade: remove any limits set for ROOT domain
This commit is contained in:
		
							parent
							
								
									37a7989623
								
							
						
					
					
						commit
						08bb9eaf47
					
				| @ -231,6 +231,10 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{ | ||||
|     public long findCorrectResourceLimitForDomain(Domain domain, ResourceType type) { | ||||
|         long max = Resource.RESOURCE_UNLIMITED; | ||||
|          | ||||
|         //no limits on ROOT domain | ||||
|         if(domain.getId() == Domain.ROOT_DOMAIN){ | ||||
|             return Resource.RESOURCE_UNLIMITED; | ||||
|         } | ||||
|         // Check account | ||||
|         ResourceLimitVO limit = _resourceLimitDao.findByOwnerIdAndType(domain.getId(), ResourceOwnerType.Domain, type); | ||||
| 
 | ||||
| @ -240,6 +244,10 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{ | ||||
|             // check domain hierarchy | ||||
|             Long domainId = domain.getParent(); | ||||
|             while ((domainId != null) && (limit == null)) { | ||||
|                  | ||||
|                 if(domainId == Domain.ROOT_DOMAIN){ | ||||
|                     return Resource.RESOURCE_UNLIMITED; | ||||
|                 } | ||||
|                 limit = _resourceLimitDao.findByOwnerIdAndType(domainId, ResourceOwnerType.Domain, type); | ||||
|                 DomainVO tmpDomain = _domainDao.findById(domainId); | ||||
|                 domainId = tmpDomain.getParent(); | ||||
| @ -299,6 +307,8 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{ | ||||
| 
 | ||||
|             while (domainId != null) { | ||||
|                 DomainVO domain = _domainDao.findById(domainId); | ||||
|                 //no limit check if it is ROOT domain | ||||
|                 if(domainId != Domain.ROOT_DOMAIN){ | ||||
|                     ResourceLimitVO domainLimit = _resourceLimitDao.findByOwnerIdAndType(domainId, ResourceOwnerType.Domain, type); | ||||
|                     if (domainLimit != null && domainLimit.getMax().longValue() != Resource.RESOURCE_UNLIMITED) { | ||||
|                         long domainCount = _resourceCountDao.getResourceCount(domainId, ResourceOwnerType.Domain, type); | ||||
| @ -306,7 +316,7 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{ | ||||
|                             throw new ResourceAllocationException("Maximum number of resources of type '" + type + "' for domain id=" + domainId + " has been exceeded.", type); | ||||
|                         } | ||||
|                     } | ||||
|                  | ||||
|                 } | ||||
|                 domainId = domain.getParent(); | ||||
|             } | ||||
|         } finally { | ||||
| @ -503,6 +513,12 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{ | ||||
|             | ||||
|             _accountMgr.checkAccess(caller, domain); | ||||
| 
 | ||||
|             if (Domain.ROOT_DOMAIN == domainId.longValue()) { | ||||
|                 // no one can add limits on ROOT domain, disallow... | ||||
|                 throw new PermissionDeniedException("Cannot update resource limit for ROOT domain " + domainId + ", permission denied"); | ||||
|             } | ||||
| 
 | ||||
|              | ||||
|             if ((caller.getDomainId() == domainId.longValue()) && caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) { | ||||
|                 // if the admin is trying to update their own domain, disallow... | ||||
|                 throw new PermissionDeniedException("Unable to update resource limit for domain " + domainId + ", permission denied"); | ||||
|  | ||||
| @ -616,3 +616,5 @@ UPDATE `cloud`.`event` e set e.domain_id = (select acc.domain_id from account ac | ||||
| update vm_template set removed=now() where id=2; | ||||
| 
 | ||||
| DELETE from `cloud`.`configuration` where name='firewall.rule.ui.enabled'; | ||||
| 
 | ||||
| DELETE FROM `cloud`.`resource_limit` WHERE domain_id = 1 AND account_id IS NULL; | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user