Search in sources :

Example 1 with VolumeMetricsResponse

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

the class MetricsServiceImpl method listVolumeMetrics.

@Override
public List<VolumeMetricsResponse> listVolumeMetrics(List<VolumeResponse> volumeResponses) {
    final List<VolumeMetricsResponse> metricsResponses = new ArrayList<>();
    for (final VolumeResponse volumeResponse : volumeResponses) {
        VolumeMetricsResponse metricsResponse = new VolumeMetricsResponse();
        try {
            BeanUtils.copyProperties(metricsResponse, volumeResponse);
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to generate volume metrics response");
        }
        metricsResponse.setDiskSizeGB(volumeResponse.getSize());
        metricsResponse.setStorageType(volumeResponse.getStorageType(), volumeResponse.getVolumeType());
        metricsResponses.add(metricsResponse);
    }
    return metricsResponses;
}
Also used : VolumeMetricsResponse(org.apache.cloudstack.response.VolumeMetricsResponse) VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 VolumeResponse (org.apache.cloudstack.api.response.VolumeResponse)1 VolumeMetricsResponse (org.apache.cloudstack.response.VolumeMetricsResponse)1