use of org.apache.cloudstack.api.response.VolumeResponse in project cloudstack by apache.
the class ViewResponseHelper method createVolumeResponse.
public static List<VolumeResponse> createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) {
Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<Long, VolumeResponse>();
for (VolumeJoinVO vr : volumes) {
VolumeResponse vrData = vrDataList.get(vr.getId());
if (vrData == null) {
// first time encountering this volume
vrData = ApiDBUtils.newVolumeResponse(view, vr);
} else {
// update tags
vrData = ApiDBUtils.fillVolumeDetails(view, vrData, vr);
}
vrDataList.put(vr.getId(), vrData);
}
return new ArrayList<VolumeResponse>(vrDataList.values());
}
use of org.apache.cloudstack.api.response.VolumeResponse 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;
}
use of org.apache.cloudstack.api.response.VolumeResponse in project cloudstack by apache.
the class QueryManagerImpl method searchForVolumes.
@Override
public ListResponse<VolumeResponse> searchForVolumes(ListVolumesCmd cmd) {
Pair<List<VolumeJoinVO>, Integer> result = searchForVolumesInternal(cmd);
ListResponse<VolumeResponse> response = new ListResponse<VolumeResponse>();
ResponseView respView = ResponseView.Restricted;
if (cmd instanceof ListVolumesCmdByAdmin) {
respView = ResponseView.Full;
}
List<VolumeResponse> volumeResponses = ViewResponseHelper.createVolumeResponse(respView, result.first().toArray(new VolumeJoinVO[result.first().size()]));
for (VolumeResponse vr : volumeResponses) {
String poolId = vr.getStoragePoolId();
if (poolId == null) {
continue;
}
DataStore store = dataStoreManager.getPrimaryDataStore(poolId);
if (store == null) {
continue;
}
DataStoreDriver driver = store.getDriver();
if (driver == null) {
continue;
}
Map<String, String> caps = driver.getCapabilities();
if (caps != null) {
boolean quiescevm = Boolean.parseBoolean(caps.get(DataStoreCapabilities.VOLUME_SNAPSHOT_QUIESCEVM.toString()));
vr.setNeedQuiescevm(quiescevm);
}
}
response.setResponses(volumeResponses, result.second());
return response;
}
Aggregations