private void checkAccountResourceLimit(final Account account, final Project project, final ResourceType type, long numResources) throws ResourceAllocationException { // Check account limits long accountResourceLimit = findCorrectResourceLimitForAccount(account, type); long currentResourceCount = _resourceCountDao.getResourceCount(account.getId(), ResourceOwnerType.Account, type); long requestedResourceCount = currentResourceCount + numResources; String messageSuffix = " amount of resources of Type = '" + type + "' for " + (project == null ? "Account Name = " + account.getAccountName() : "Project Name = " + project.getName()) + " in Domain Id = " + account.getDomainId() + " is exceeded: Account Resource Limit = " + accountResourceLimit + ", Current Account Resource Amount = " + currentResourceCount + ", Requested Resource Amount = " + numResources + "."; if (s_logger.isDebugEnabled()) { s_logger.debug("Checking if" + messageSuffix); } if (accountResourceLimit != Resource.RESOURCE_UNLIMITED && requestedResourceCount > accountResourceLimit) { String message = "Maximum" + messageSuffix; ResourceAllocationException e = new ResourceAllocationException(message, type); s_logger.error(message, e); throw e; } }
private void checkDomainResourceLimit(final Account account, final Project project, final ResourceType type, long numResources) throws ResourceAllocationException { // check all domains in the account's domain hierarchy Long domainId = null; if (project != null) { domainId = project.getDomainId(); } else { domainId = account.getDomainId(); } while (domainId != null) { DomainVO domain = _domainDao.findById(domainId); // no limit check if it is ROOT domain if (domainId != Domain.ROOT_DOMAIN) { long domainResourceLimit = findCorrectResourceLimitForDomain(domain, type); long currentDomainResourceCount = _resourceCountDao.getResourceCount(domainId, ResourceOwnerType.Domain, type); long requestedDomainResourceCount = currentDomainResourceCount + numResources; String messageSuffix = " domain resource limits of Type '" + type + "'" + " for Domain Id = " + domainId + " is exceeded: Domain Resource Limit = " + domainResourceLimit + ", Current Domain Resource Amount = " + currentDomainResourceCount + ", Requested Resource Amount = " + numResources + "."; if (s_logger.isDebugEnabled()) { s_logger.debug("Checking if" + messageSuffix); } if (domainResourceLimit != Resource.RESOURCE_UNLIMITED && requestedDomainResourceCount > domainResourceLimit) { String message = "Maximum" + messageSuffix; ResourceAllocationException e = new ResourceAllocationException(message, type); s_logger.error(message, e); throw e; } } domainId = domain.getParent(); } }
Account caller = CallContext.current().getCallingAccount(); if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getId())) { ResourceAllocationException ex = new ResourceAllocationException("Cannot perform this operation, " + "Zone is currently disabled" + "zoneId=" + zone.getUuid(), ResourceType.network); throw ex; throw new ResourceAllocationException("Please do not provide NULL podId", ResourceType.network); HostPodVO podvo = null; podvo = _hpDao.findByUuid(podId); if (podvo == null) throw new ResourceAllocationException("No sush pod exists", ResourceType.network); throw new ResourceAllocationException("Unable to allocate IP from this Pod", ResourceType.network); if (vo.getIpAddress() == null) throw new ResourceAllocationException("Unable to allocate IP from this Pod", ResourceType.network);