Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -573,25 +573,16 @@ public long getUsedIops(StoragePoolVO pool) {
throw new CloudRuntimeException("Storage driver in CapacityManagerImpl.getUsedIops(StoragePoolVO) is not a PrimaryDataStoreDriver.");
}

//Managed pool, return value contains used size of the pool.
//Unmanaged pool, return value contains used pool size and template size.
@Override
public long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateForVmCreation) {
long totalAllocatedSize;

// if the storage pool is managed, the used bytes can be larger than the sum of the sizes of all of the non-destroyed volumes
// in this case, call getUsedBytes(StoragePoolVO)
if (pool.isManaged()) {
totalAllocatedSize = getUsedBytes(pool);

if (templateForVmCreation != null) {
VMTemplateStoragePoolVO templatePoolVO = _templatePoolDao.findByPoolTemplate(pool.getId(), templateForVmCreation.getId(), null);
if (templatePoolVO == null) {
// template is not installed in the pool, consider the template size for allocation
long templateForVmCreationSize = templateForVmCreation.getSize() != null ? templateForVmCreation.getSize() : 0;
totalAllocatedSize += templateForVmCreationSize;
}
}

return totalAllocatedSize;
return getUsedBytes(pool);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any inputs on this change? Should this cause any regressions? cc @sureshanaparti @slavkap @rp-

} else {
// Get size for all the non-destroyed volumes.
Pair<Long, Long> sizes = _volumeDao.getNonDestroyedCountAndTotalByPool(pool.getId());
Expand Down
Loading