use of com.emc.storageos.cinder.model.UsageAndLimits in project coprhd-controller by CoprHD.
the class QuotaHelper method getUsageStatistics.
/**
* Get usage statistics in terms of quota attributes like gigabytes,snapshots, volumes.
* The details include in_use,reserved,limit.
*
* @prereq none
*
* @param tenantId
* @param quotaMap of project and vpools
* @param proj project under consideration
*
* @brief get usage statistics in terms of project and volume types.
* @return CinderUsage
*/
public CinderUsage getUsageStatistics(URI tenantId, HashMap<String, String> quotaMap, Project proj) {
CinderUsage objCinderUsage = new CinderUsage();
List<URI> vpools = _dbClient.queryByType(VirtualPool.class, true);
for (URI vpool : vpools) {
VirtualPool pool = _dbClient.queryObject(VirtualPool.class, vpool);
_log.debug("Looking up vpool {}", pool.getLabel());
if (pool != null && pool.getType().equalsIgnoreCase(VirtualPool.Type.block.name())) {
if (_permissionsHelper.tenantHasUsageACL(tenantId, pool)) {
UsageStats stats = getStorageStats(pool.getId(), proj.getId());
UsageAndLimits objSpaceUsage = new UsageAndLimits();
objSpaceUsage.setIn_use(stats.spaceUsed);
objSpaceUsage.setLimit(Long.parseLong(quotaMap.get("gigabytes" + "_" + pool.getLabel())));
UsageAndLimits objVolsUsage = new UsageAndLimits();
objVolsUsage.setIn_use(stats.volumes);
objVolsUsage.setLimit(Long.parseLong(quotaMap.get("volumes" + "_" + pool.getLabel())));
UsageAndLimits objSnapsUsage = new UsageAndLimits();
objSnapsUsage.setIn_use(stats.snapshots);
objSnapsUsage.setLimit(Long.parseLong(quotaMap.get("snapshots" + "_" + pool.getLabel())));
objCinderUsage.getQuota_set().put("gigabytes" + "_" + pool.getLabel(), objSpaceUsage);
objCinderUsage.getQuota_set().put("snapshots" + "_" + pool.getLabel(), objSnapsUsage);
objCinderUsage.getQuota_set().put("volumes" + "_" + pool.getLabel(), objVolsUsage);
}
}
}
// now get the usage information for the project
UsageStats stats = getStorageStats(null, proj.getId());
UsageAndLimits objSpaceUsage = new UsageAndLimits();
objSpaceUsage.setIn_use(stats.spaceUsed);
objSpaceUsage.setLimit(Long.parseLong(quotaMap.get("gigabytes")));
UsageAndLimits objVolsUsage = new UsageAndLimits();
objVolsUsage.setIn_use(stats.volumes);
objVolsUsage.setLimit(Long.parseLong(quotaMap.get("volumes")));
UsageAndLimits objSnapsUsage = new UsageAndLimits();
objSnapsUsage.setIn_use(stats.snapshots);
objSnapsUsage.setLimit(Long.parseLong(quotaMap.get("snapshots")));
objCinderUsage.getQuota_set().put("gigabytes", objSpaceUsage);
objCinderUsage.getQuota_set().put("snapshots", objSnapsUsage);
objCinderUsage.getQuota_set().put("volumes", objVolsUsage);
return objCinderUsage;
}
Aggregations