Search in sources :

Example 1 with StoragePoolMetricsResponse

use of org.apache.cloudstack.response.StoragePoolMetricsResponse in project cloudstack by apache.

the class MetricsServiceImpl method listStoragePoolMetrics.

@Override
public List<StoragePoolMetricsResponse> listStoragePoolMetrics(List<StoragePoolResponse> poolResponses) {
    final List<StoragePoolMetricsResponse> metricsResponses = new ArrayList<>();
    for (final StoragePoolResponse poolResponse : poolResponses) {
        StoragePoolMetricsResponse metricsResponse = new StoragePoolMetricsResponse();
        try {
            BeanUtils.copyProperties(metricsResponse, poolResponse);
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to generate storagepool metrics response");
        }
        Long poolClusterId = null;
        final Cluster cluster = clusterDao.findByUuid(poolResponse.getClusterId());
        if (cluster != null) {
            poolClusterId = cluster.getId();
        }
        final Double storageThreshold = AlertManager.StorageCapacityThreshold.valueIn(poolClusterId);
        final Double storageDisableThreshold = CapacityManager.StorageCapacityDisableThreshold.valueIn(poolClusterId);
        metricsResponse.setDiskSizeUsedGB(poolResponse.getDiskSizeUsed());
        metricsResponse.setDiskSizeTotalGB(poolResponse.getDiskSizeTotal(), poolResponse.getOverProvisionFactor());
        metricsResponse.setDiskSizeAllocatedGB(poolResponse.getDiskSizeAllocated());
        metricsResponse.setDiskSizeUnallocatedGB(poolResponse.getDiskSizeTotal(), poolResponse.getDiskSizeAllocated(), poolResponse.getOverProvisionFactor());
        metricsResponse.setStorageUsedThreshold(poolResponse.getDiskSizeTotal(), poolResponse.getDiskSizeUsed(), poolResponse.getOverProvisionFactor(), storageThreshold);
        metricsResponse.setStorageUsedDisableThreshold(poolResponse.getDiskSizeTotal(), poolResponse.getDiskSizeUsed(), poolResponse.getOverProvisionFactor(), storageDisableThreshold);
        metricsResponse.setStorageAllocatedThreshold(poolResponse.getDiskSizeTotal(), poolResponse.getDiskSizeAllocated(), poolResponse.getOverProvisionFactor(), storageThreshold);
        metricsResponse.setStorageAllocatedDisableThreshold(poolResponse.getDiskSizeTotal(), poolResponse.getDiskSizeUsed(), poolResponse.getOverProvisionFactor(), storageDisableThreshold);
        metricsResponses.add(metricsResponse);
    }
    return metricsResponses;
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) StoragePoolMetricsResponse(org.apache.cloudstack.response.StoragePoolMetricsResponse) ArrayList(java.util.ArrayList) Cluster(com.cloud.org.Cluster) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Cluster (com.cloud.org.Cluster)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 StoragePoolResponse (org.apache.cloudstack.api.response.StoragePoolResponse)1 StoragePoolMetricsResponse (org.apache.cloudstack.response.StoragePoolMetricsResponse)1