mirror of https://github.com/apache/cloudstack.git
Get allocated size for datastoreCluster from its child datastores to show the accumalated value for Datastore cluster
This commit is contained in:
parent
78aa3df440
commit
1638d7243c
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue