Search in sources :

Example 6 with StoragePoolResponse

use of com.cloud.api.response.StoragePoolResponse in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method searchForStoragePools.

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

Example 7 with StoragePoolResponse

use of com.cloud.api.response.StoragePoolResponse in project cosmic by MissionCriticalCloud.

the class StoragePoolJoinDaoImpl method newStoragePoolForMigrationResponse.

@Override
public StoragePoolResponse newStoragePoolForMigrationResponse(final StoragePoolJoinVO pool) {
    final 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());
    }
    final 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
    final StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
    if (stats != null) {
        final 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(com.cloud.api.response.StoragePoolResponse) StorageStats(com.cloud.storage.StorageStats)

Example 8 with StoragePoolResponse

use of com.cloud.api.response.StoragePoolResponse in project cosmic by MissionCriticalCloud.

the class StoragePoolJoinDaoImpl method newStoragePoolResponse.

@Override
public StoragePoolResponse newStoragePoolResponse(final StoragePoolJoinVO pool) {
    final 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());
    }
    final long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();
    poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
    poolResponse.setDiskSizeAllocated(allocatedSize);
    poolResponse.setCapacityIops(pool.getCapacityIops());
    // TODO: StatsCollector does not persist data
    final StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
    if (stats != null) {
        final 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(com.cloud.api.response.StoragePoolResponse) StorageStats(com.cloud.storage.StorageStats)

Example 9 with StoragePoolResponse

use of com.cloud.api.response.StoragePoolResponse in project CloudStack-archive by CloudStack-extras.

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(BaseCmd.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
    }
}
Also used : StoragePoolResponse(com.cloud.api.response.StoragePoolResponse) StoragePool(com.cloud.storage.StoragePool) ServerApiException(com.cloud.api.ServerApiException)

Example 10 with StoragePoolResponse

use of com.cloud.api.response.StoragePoolResponse in project CloudStack-archive by CloudStack-extras.

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(BaseCmd.INTERNAL_ERROR, "Failed to add storage pool");
        }
    } catch (ResourceUnavailableException ex1) {
        s_logger.warn("Exception: ", ex1);
        throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
    } catch (ResourceInUseException ex2) {
        s_logger.warn("Exception: ", ex2);
        throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex2.getMessage());
    } catch (UnknownHostException ex3) {
        s_logger.warn("Exception: ", ex3);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex3.getMessage());
    }
}
Also used : StoragePoolResponse(com.cloud.api.response.StoragePoolResponse) StoragePool(com.cloud.storage.StoragePool) ServerApiException(com.cloud.api.ServerApiException) UnknownHostException(java.net.UnknownHostException) ResourceInUseException(com.cloud.exception.ResourceInUseException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

Aggregations

StoragePoolResponse (com.cloud.api.response.StoragePoolResponse)15 StoragePool (com.cloud.storage.StoragePool)10 ServerApiException (com.cloud.api.ServerApiException)8 ArrayList (java.util.ArrayList)5 StoragePoolJoinVO (com.cloud.api.query.vo.StoragePoolJoinVO)3 ListResponse (com.cloud.api.response.ListResponse)3 ResourceInUseException (com.cloud.exception.ResourceInUseException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 StorageStats (com.cloud.storage.StorageStats)2 UnknownHostException (java.net.UnknownHostException)2 Hashtable (java.util.Hashtable)2 List (java.util.List)2 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)1 DataStoreDriver (com.cloud.engine.subsystem.api.storage.DataStoreDriver)1