Skip to content

Commit 47419df

Browse files
syedyadvr
authored andcommitted
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.
1 parent b417226 commit 47419df

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public class StoragePoolResponse extends BaseResponse {
9393
@Param(description = "IOPS CloudStack can provision from this storage pool")
9494
private Long capacityIops;
9595

96+
@SerializedName("allocatediops")
97+
@Param(description = "total min IOPS currently in use by volumes")
98+
private Long allocatedIops;
99+
96100
@SerializedName("tags")
97101
@Param(description = "the tags for the storage pool")
98102
private String tags;
@@ -288,6 +292,10 @@ public void setCapacityIops(Long capacityIops) {
288292
this.capacityIops = capacityIops;
289293
}
290294

295+
public void setAllocatedIops(Long allocatedIops) {
296+
this.allocatedIops = allocatedIops;
297+
}
298+
291299
public String getTags() {
292300
return tags;
293301
}

server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@
1919
import com.cloud.api.ApiDBUtils;
2020
import com.cloud.api.query.vo.StoragePoolJoinVO;
2121
import com.cloud.capacity.CapacityManager;
22+
import com.cloud.storage.DataStoreRole;
2223
import com.cloud.storage.StoragePool;
2324
import com.cloud.storage.StorageStats;
2425
import com.cloud.utils.StringUtils;
2526
import com.cloud.utils.db.GenericDaoBase;
2627
import com.cloud.utils.db.SearchBuilder;
2728
import com.cloud.utils.db.SearchCriteria;
2829
import org.apache.cloudstack.api.response.StoragePoolResponse;
30+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
31+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
32+
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
2933
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
34+
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
3035
import org.apache.log4j.Logger;
3136
import org.springframework.stereotype.Component;
3237

@@ -41,6 +46,12 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
4146
@Inject
4247
private ConfigurationDao _configDao;
4348

49+
@Inject
50+
private DataStoreManager dataStoreMgr;
51+
52+
@Inject
53+
protected PrimaryDataStoreDao storagePoolDao;
54+
4455
private final SearchBuilder<StoragePoolJoinVO> spSearch;
4556

4657
private final SearchBuilder<StoragePoolJoinVO> spIdSearch;
@@ -60,6 +71,7 @@ protected StoragePoolJoinDaoImpl() {
6071

6172
@Override
6273
public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool) {
74+
StoragePool storagePool = storagePoolDao.findById(pool.getId());
6375
StoragePoolResponse poolResponse = new StoragePoolResponse();
6476
poolResponse.setId(pool.getUuid());
6577
poolResponse.setName(pool.getName());
@@ -87,6 +99,13 @@ public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool) {
8799
poolResponse.setDiskSizeAllocated(allocatedSize);
88100
poolResponse.setCapacityIops(pool.getCapacityIops());
89101

102+
if (storagePool.isManaged()) {
103+
DataStore store = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
104+
PrimaryDataStoreDriver driver = (PrimaryDataStoreDriver) store.getDriver();
105+
long usedIops = driver.getUsedIops(storagePool);
106+
poolResponse.setAllocatedIops(usedIops);
107+
}
108+
90109
// TODO: StatsCollector does not persist data
91110
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
92111
if (stats != null) {

ui/l10n/en.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ var dictionary = {"ICMP.code":"ICMP Code",
664664
"label.disk.iops.min":"Min IOPS",
665665
"label.disk.iops.read.rate":"Disk Read Rate (IOPS)",
666666
"label.disk.iops.total":"IOPS Total",
667+
"label.disk.iops.allocated":"IOPS Allocated",
667668
"label.disk.iops.write.rate":"Disk Write Rate (IOPS)",
668669
"label.disk.offering":"Disk Offering",
669670
"label.disk.offering.details":"Disk offering details",

ui/scripts/system.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18778,6 +18778,15 @@
1877818778
return ""; else
1877918779
return args;
1878018780
}
18781+
},
18782+
allocatediops: {
18783+
label: 'label.disk.iops.allocated',
18784+
isEditable: false,
18785+
converter: function (args) {
18786+
if (args == null || args == 0)
18787+
return ""; else
18788+
return args;
18789+
}
1878118790
}
1878218791
}],
1878318792

0 commit comments

Comments
 (0)