Search in sources :

Example 6 with StoragePoolResponse

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");
    }
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) StoragePool(com.cloud.storage.StoragePool) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 7 with StoragePoolResponse

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);
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) StoragePool(com.cloud.storage.StoragePool) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with StoragePoolResponse

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");
    }
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) StoragePool(com.cloud.storage.StoragePool) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 9 with StoragePoolResponse

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());
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) StoragePoolJoinVO(com.cloud.api.query.vo.StoragePoolJoinVO)

Example 10 with StoragePoolResponse

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;
}
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

StoragePoolResponse (org.apache.cloudstack.api.response.StoragePoolResponse)11 StoragePool (com.cloud.storage.StoragePool)5 ArrayList (java.util.ArrayList)5 ServerApiException (org.apache.cloudstack.api.ServerApiException)5 StoragePoolJoinVO (com.cloud.api.query.vo.StoragePoolJoinVO)3 StorageStats (com.cloud.storage.StorageStats)2 Hashtable (java.util.Hashtable)2 List (java.util.List)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 ResourceInUseException (com.cloud.exception.ResourceInUseException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 Cluster (com.cloud.org.Cluster)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 UnknownHostException (java.net.UnknownHostException)1 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)1 DataStoreDriver (org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver)1 StoragePoolMetricsResponse (org.apache.cloudstack.response.StoragePoolMetricsResponse)1