CLOUDSTACK-10039: Adding used IOPS to storage pool response (#2294)

This change adds allocatediops to the ListStoragePool API. This applies to managed storage where we have a guaranteed minimum IOPS set. This is useful for monitoring if we have reached the IOPS limit on a storage cluster.
This commit is contained in:
Syed Mushtaq Ahmed 2017-12-15 07:42:13 -05:00 committed by Rohit Yadav
parent b417226d05
commit 47419df368
4 changed files with 37 additions and 0 deletions

View File

@ -93,6 +93,10 @@ public class StoragePoolResponse extends BaseResponse {
@Param(description = "IOPS CloudStack can provision from this storage pool")
private Long capacityIops;
@SerializedName("allocatediops")
@Param(description = "total min IOPS currently in use by volumes")
private Long allocatedIops;
@SerializedName("tags")
@Param(description = "the tags for the storage pool")
private String tags;
@ -288,6 +292,10 @@ public class StoragePoolResponse extends BaseResponse {
this.capacityIops = capacityIops;
}
public void setAllocatedIops(Long allocatedIops) {
this.allocatedIops = allocatedIops;
}
public String getTags() {
return tags;
}

View File

@ -19,6 +19,7 @@ package com.cloud.api.query.dao;
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.StoragePool;
import com.cloud.storage.StorageStats;
import com.cloud.utils.StringUtils;
@ -26,7 +27,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -41,6 +46,12 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
@Inject
private ConfigurationDao _configDao;
@Inject
private DataStoreManager dataStoreMgr;
@Inject
protected PrimaryDataStoreDao storagePoolDao;
private final SearchBuilder<StoragePoolJoinVO> spSearch;
private final SearchBuilder<StoragePoolJoinVO> spIdSearch;
@ -60,6 +71,7 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
@Override
public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool) {
StoragePool storagePool = storagePoolDao.findById(pool.getId());
StoragePoolResponse poolResponse = new StoragePoolResponse();
poolResponse.setId(pool.getUuid());
poolResponse.setName(pool.getName());
@ -87,6 +99,13 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
poolResponse.setDiskSizeAllocated(allocatedSize);
poolResponse.setCapacityIops(pool.getCapacityIops());
if (storagePool.isManaged()) {
DataStore store = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
PrimaryDataStoreDriver driver = (PrimaryDataStoreDriver) store.getDriver();
long usedIops = driver.getUsedIops(storagePool);
poolResponse.setAllocatedIops(usedIops);
}
// TODO: StatsCollector does not persist data
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
if (stats != null) {

View File

@ -664,6 +664,7 @@ var dictionary = {"ICMP.code":"ICMP Code",
"label.disk.iops.min":"Min IOPS",
"label.disk.iops.read.rate":"Disk Read Rate (IOPS)",
"label.disk.iops.total":"IOPS Total",
"label.disk.iops.allocated":"IOPS Allocated",
"label.disk.iops.write.rate":"Disk Write Rate (IOPS)",
"label.disk.offering":"Disk Offering",
"label.disk.offering.details":"Disk offering details",

View File

@ -18778,6 +18778,15 @@
return ""; else
return args;
}
},
allocatediops: {
label: 'label.disk.iops.allocated',
isEditable: false,
converter: function (args) {
if (args == null || args == 0)
return ""; else
return args;
}
}
}],