bug 5942,7164 : For pool allocation calculation while creating vm’s we consider templates but not on the dashboard - correcting that.

While creating a vm if a pool is not adequate to create the vm's volume then improving the misleading verbiage of the log message.
This commit is contained in:
nit 2010-12-20 15:07:12 +05:30
parent 2c891d5b77
commit 0de8921d57
4 changed files with 23 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import java.util.Map;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.to.VolumeTO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.exception.InternalErrorException;
@ -274,4 +275,9 @@ public interface StorageManager extends Manager {
void createCapacityEntry(StoragePoolVO storagePool, long allocated);
/**
* Calculates the sum of all template sizes in the pool.
*/
long calculateAllTemplateSizesInPool(StoragePoolVO pool);
}

View File

@ -381,6 +381,7 @@ public class AlertManagerImpl implements AlertManager {
long disk = 0l;
Pair<Long, Long> sizes = _volumeDao.getCountAndTotalByPool(pool.getId());
disk = sizes.second();
disk += _storageMgr.calculateAllTemplateSizesInPool(pool);
_storageMgr.createCapacityEntry(pool, disk);
}

View File

@ -1651,6 +1651,20 @@ public class StorageManagerImpl implements StorageManager {
s_logger.debug("Successfully set Capacity - " +storagePool.getCapacityBytes()* _overProvisioningFactor+ " for CAPACITY_TYPE_STORAGE_ALLOCATED, DataCenterId - " +storagePool.getDataCenterId()+ ", HostOrPoolId - " +storagePool.getId()+ ", PodId " +storagePool.getPodId());
}
@Override
//TO DO - use this in AbstractpoolAllocator.checkPool.
public long calculateAllTemplateSizesInPool(StoragePoolVO pool){
List<VMTemplateStoragePoolVO> templatePoolVOs = _vmTemplatePoolDao.listByPoolId(pool.getId());
long totalAllocatedSize = 0l;
long extraBytesPerVolume = 0l;
for (VMTemplateStoragePoolVO templatePoolVO : templatePoolVOs) {
long templateSize = templatePoolVO.getTemplateSize();
totalAllocatedSize += templateSize + extraBytesPerVolume;
}
return totalAllocatedSize;
}
@Override
public Answer sendToHostsOnStoragePool(Long poolId, Command cmd, String basicErrMsg) {
return sendToHostsOnStoragePool(poolId, cmd, basicErrMsg, 1, 0, false);

View File

@ -173,6 +173,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
long totalAllocatedSize = sizes.second() + (long)sizes.first() * _extraBytesPerVolume;
// TO DO - abstract this out. The dashboard should also use the same calculation. (@AlertManagerImpl)
// Iterate through all templates on this storage pool
boolean tmpinstalled = false;
List<VMTemplateStoragePoolVO> templatePoolVOs;
@ -213,7 +214,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
if ((pool.getCapacityBytes() * storageOverprovisioningFactor) < (totalAllocatedSize + askingSize)) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Found pool " + pool.getId() + " for storage, maxSize : " + (pool.getCapacityBytes() * storageOverprovisioningFactor) + ", totalSize : " + totalAllocatedSize + ", askingSize : " + askingSize);
s_logger.debug("Pool " + pool.getId() + " doesnt have sufficient allocation bandwidth, with maxAllocationSize : " + (pool.getCapacityBytes() * storageOverprovisioningFactor) + ", totalAllocatedSize : " + totalAllocatedSize + ", askingAllocationSize : " + askingSize);
}
return false;