Search in sources :

Example 1 with StoragePoolResponse

use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.

the class StoragePoolJoinDaoImpl method newStoragePoolResponse.

@Override
public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool) {
    StoragePoolResponse poolResponse = new StoragePoolResponse();
    poolResponse.setId(pool.getUuid());
    poolResponse.setName(pool.getName());
    poolResponse.setState(pool.getStatus());
    String path = pool.getPath();
    //cifs store may contain password entry, remove the password
    path = StringUtils.cleanString(path);
    poolResponse.setPath(path);
    poolResponse.setIpAddress(pool.getHostAddress());
    poolResponse.setZoneId(pool.getZoneUuid());
    poolResponse.setZoneName(pool.getZoneName());
    poolResponse.setType(pool.getPoolType().toString());
    poolResponse.setPodId(pool.getPodUuid());
    poolResponse.setPodName(pool.getPodName());
    poolResponse.setCreated(pool.getCreated());
    if (pool.getScope() != null) {
        poolResponse.setScope(pool.getScope().toString());
    }
    if (pool.getHypervisor() != null) {
        poolResponse.setHypervisor(pool.getHypervisor().toString());
    }
    long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();
    poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
    poolResponse.setDiskSizeAllocated(allocatedSize);
    poolResponse.setCapacityIops(pool.getCapacityIops());
    // TODO: StatsCollector does not persist data
    StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
    if (stats != null) {
        Long used = stats.getByteUsed();
        poolResponse.setDiskSizeUsed(used);
    }
    poolResponse.setClusterId(pool.getClusterUuid());
    poolResponse.setClusterName(pool.getClusterName());
    poolResponse.setTags(pool.getTag());
    poolResponse.setOverProvisionFactor(Double.toString(CapacityManager.StorageOverprovisioningFactor.valueIn(pool.getId())));
    // set async job
    if (pool.getJobId() != null) {
        poolResponse.setJobId(pool.getJobUuid());
        poolResponse.setJobStatus(pool.getJobStatus());
    }
    poolResponse.setObjectName("storagepool");
    return poolResponse;
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) StorageStats(com.cloud.storage.StorageStats)

Example 2 with StoragePoolResponse

use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.

the class StoragePoolJoinDaoImpl method newStoragePoolForMigrationResponse.

@Override
public StoragePoolResponse newStoragePoolForMigrationResponse(StoragePoolJoinVO pool) {
    StoragePoolResponse poolResponse = new StoragePoolResponse();
    poolResponse.setId(pool.getUuid());
    poolResponse.setName(pool.getName());
    poolResponse.setState(pool.getStatus());
    String path = pool.getPath();
    //cifs store may contain password entry, remove the password
    path = StringUtils.cleanString(path);
    poolResponse.setPath(path);
    poolResponse.setIpAddress(pool.getHostAddress());
    poolResponse.setZoneId(pool.getZoneUuid());
    poolResponse.setZoneName(pool.getZoneName());
    if (pool.getPoolType() != null) {
        poolResponse.setType(pool.getPoolType().toString());
    }
    poolResponse.setPodId(pool.getPodUuid());
    poolResponse.setPodName(pool.getPodName());
    poolResponse.setCreated(pool.getCreated());
    poolResponse.setScope(pool.getScope().toString());
    if (pool.getHypervisor() != null) {
        poolResponse.setHypervisor(pool.getHypervisor().toString());
    }
    long allocatedSize = pool.getUsedCapacity();
    poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
    poolResponse.setDiskSizeAllocated(allocatedSize);
    poolResponse.setCapacityIops(pool.getCapacityIops());
    poolResponse.setOverProvisionFactor(Double.toString(CapacityManager.StorageOverprovisioningFactor.valueIn(pool.getId())));
    // TODO: StatsCollector does not persist data
    StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
    if (stats != null) {
        Long used = stats.getByteUsed();
        poolResponse.setDiskSizeUsed(used);
    }
    poolResponse.setClusterId(pool.getClusterUuid());
    poolResponse.setClusterName(pool.getClusterName());
    poolResponse.setTags(pool.getTag());
    // set async job
    poolResponse.setJobId(pool.getJobUuid());
    poolResponse.setJobStatus(pool.getJobStatus());
    poolResponse.setObjectName("storagepool");
    return poolResponse;
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) StorageStats(com.cloud.storage.StorageStats)

Example 3 with StoragePoolResponse

use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.

the class CreateStoragePoolCmd method execute.

@Override
public void execute() {
    try {
        StoragePool result = _storageService.createPool(this);
        if (result != null) {
            StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add storage pool");
        }
    } catch (ResourceUnavailableException ex1) {
        s_logger.warn("Exception: ", ex1);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
    } catch (ResourceInUseException ex2) {
        s_logger.warn("Exception: ", ex2);
        throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex2.getMessage());
    } catch (UnknownHostException ex3) {
        s_logger.warn("Exception: ", ex3);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex3.getMessage());
    } catch (Exception ex4) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex4.getMessage());
    }
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) StoragePool(com.cloud.storage.StoragePool) ServerApiException(org.apache.cloudstack.api.ServerApiException) UnknownHostException(java.net.UnknownHostException) ResourceInUseException(com.cloud.exception.ResourceInUseException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) UnknownHostException(java.net.UnknownHostException) ResourceInUseException(com.cloud.exception.ResourceInUseException)

Example 4 with StoragePoolResponse

use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.

the class PreparePrimaryStorageForMaintenanceCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException {
    StoragePool result = _storageService.preparePrimaryStorageForMaintenance(getId());
    if (result != null) {
        StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
        response.setResponseName("storagepool");
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
    }
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) StoragePool(com.cloud.storage.StoragePool) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 5 with StoragePoolResponse

use of org.apache.cloudstack.api.response.StoragePoolResponse in project cloudstack by apache.

the class QueryManagerImpl method searchForStoragePools.

@Override
public ListResponse<StoragePoolResponse> searchForStoragePools(ListStoragePoolsCmd cmd) {
    Pair<List<StoragePoolJoinVO>, Integer> result = searchForStoragePoolsInternal(cmd);
    ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
    List<StoragePoolResponse> poolResponses = ViewResponseHelper.createStoragePoolResponse(result.first().toArray(new StoragePoolJoinVO[result.first().size()]));
    for (StoragePoolResponse poolResponse : poolResponses) {
        DataStore store = dataStoreManager.getPrimaryDataStore(poolResponse.getId());
        if (store != null) {
            DataStoreDriver driver = store.getDriver();
            if (driver != null && driver.getCapabilities() != null) {
                poolResponse.setCaps(driver.getCapabilities());
            }
        }
    }
    response.setResponses(poolResponses, result.second());
    return response;
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) StoragePoolJoinVO(com.cloud.api.query.vo.StoragePoolJoinVO) DataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver) ArrayList(java.util.ArrayList) List(java.util.List)

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