Get allocated size for datastoreCluster from its child datastores to show the accumalated value for Datastore cluster

This commit is contained in:
Harikrishna Patnala 2020-09-29 15:06:52 +05:30
parent 78aa3df440
commit 1638d7243c
1 changed files with 11 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import com.cloud.api.ApiDBUtils;
import com.cloud.api.query.vo.StoragePoolJoinVO;
import com.cloud.capacity.CapacityManager;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.Storage;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StorageStats;
import com.cloud.utils.StringUtils;
@ -34,6 +35,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -104,6 +106,15 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
poolResponse.setType(poolType.getValue());
}
long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();
if (pool.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
List<StoragePoolVO> childDatastores = storagePoolDao.listChildStoragePoolsInDatastoreCluster(pool.getId());
if (childDatastores != null) {
for (StoragePoolVO childDatastore: childDatastores) {
StoragePoolJoinVO childDSJoinVO = findById(childDatastore.getId());
allocatedSize += (childDSJoinVO.getUsedCapacity() + childDSJoinVO.getReservedCapacity());
}
}
}
poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
poolResponse.setDiskSizeAllocated(allocatedSize);
poolResponse.setCapacityIops(pool.getCapacityIops());