use of com.cloud.capacity.CapacityVO in project cloudstack by apache.
the class ManagementServerImpl method getStorageUsed.
List<SummedCapacity> getStorageUsed(Long clusterId, Long podId, Long zoneId, Integer capacityType) {
if (capacityType == null || capacityType == Capacity.CAPACITY_TYPE_SECONDARY_STORAGE) {
final List<SummedCapacity> list = new ArrayList<SummedCapacity>();
if (zoneId != null) {
final DataCenterVO zone = ApiDBUtils.findZoneById(zoneId);
if (zone == null || zone.getAllocationState() == AllocationState.Disabled) {
return null;
}
List<CapacityVO> capacities = new ArrayList<CapacityVO>();
capacities.add(_storageMgr.getSecondaryStorageUsedStats(null, zoneId));
capacities.add(_storageMgr.getStoragePoolUsedStats(null, clusterId, podId, zoneId));
for (CapacityVO capacity : capacities) {
if (capacity.getTotalCapacity() != 0) {
capacity.setUsedPercentage((float) capacity.getUsedCapacity() / capacity.getTotalCapacity());
} else {
capacity.setUsedPercentage(0);
}
final SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedCapacity(), capacity.getTotalCapacity(), capacity.getUsedPercentage(), capacity.getCapacityType(), capacity.getDataCenterId(), capacity.getPodId(), capacity.getClusterId());
list.add(summedCapacity);
}
} else {
List<DataCenterVO> dcList = _dcDao.listEnabledZones();
for (DataCenterVO dc : dcList) {
List<CapacityVO> capacities = new ArrayList<CapacityVO>();
capacities.add(_storageMgr.getSecondaryStorageUsedStats(null, dc.getId()));
capacities.add(_storageMgr.getStoragePoolUsedStats(null, null, null, dc.getId()));
for (CapacityVO capacity : capacities) {
if (capacity.getTotalCapacity() != 0) {
capacity.setUsedPercentage((float) capacity.getUsedCapacity() / capacity.getTotalCapacity());
} else {
capacity.setUsedPercentage(0);
}
SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedCapacity(), capacity.getTotalCapacity(), capacity.getUsedPercentage(), capacity.getCapacityType(), capacity.getDataCenterId(), capacity.getPodId(), capacity.getClusterId());
list.add(summedCapacity);
}
}
// End of for
}
return list;
}
return null;
}
Aggregations