use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.
the class UpdateStoragePoolCmd method execute.
@Override
public void execute() {
StoragePool result = _storageService.updateStoragePool(this);
if (result != null) {
StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update storage pool");
}
}
use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.
the class FindStoragePoolsForMigrationCmd method execute.
@Override
public void execute() {
Pair<List<? extends StoragePool>, List<? extends StoragePool>> pools = _mgr.listStoragePoolsForMigrationOfVolume(getId());
ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
List<StoragePoolResponse> poolResponses = new ArrayList<StoragePoolResponse>();
List<? extends StoragePool> allPools = pools.first();
List<? extends StoragePool> suitablePoolList = pools.second();
for (StoragePool pool : allPools) {
StoragePoolResponse poolResponse = _responseGenerator.createStoragePoolForMigrationResponse(pool);
Boolean suitableForMigration = false;
for (StoragePool suitablePool : suitablePoolList) {
if (suitablePool.getId() == pool.getId()) {
suitableForMigration = true;
break;
}
}
poolResponse.setSuitableForMigration(suitableForMigration);
poolResponse.setObjectName("storagepool");
poolResponses.add(poolResponse);
}
response.setResponses(poolResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.
the class CancelPrimaryStorageMaintenanceCmd method execute.
@Override
public void execute() throws ResourceUnavailableException {
StoragePool result = _storageService.cancelPrimaryStorageForMaintenance(this);
if (result != null) {
StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
}
}
use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.
the class ViewResponseHelper method createStoragePoolForMigrationResponse.
public static List<StoragePoolResponse> createStoragePoolForMigrationResponse(StoragePoolJoinVO... pools) {
Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
// Initialise the vrdatalist with the input data
for (StoragePoolJoinVO vr : pools) {
StoragePoolResponse vrData = vrDataList.get(vr.getId());
if (vrData == null) {
// first time encountering this vm
vrData = ApiDBUtils.newStoragePoolForMigrationResponse(vr);
} else {
// update tags
vrData = ApiDBUtils.fillStoragePoolForMigrationDetails(vrData, vr);
}
vrDataList.put(vr.getId(), vrData);
}
return new ArrayList<StoragePoolResponse>(vrDataList.values());
}
use of org.apache.cloudstack.api.response.StoragePoolResponse 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;
}
Aggregations