return groupResponse;
}
@Override
public StoragePoolResponse createStoragePoolResponse(StoragePool pool) {
StoragePoolResponse poolResponse = new StoragePoolResponse();
poolResponse.setId(pool.getId());
poolResponse.setName(pool.getName());
poolResponse.setState(pool.getStatus());
poolResponse.setPath(pool.getPath());
poolResponse.setIpAddress(pool.getHostAddress());
poolResponse.setZoneId(pool.getDataCenterId());
poolResponse.setZoneName(ApiDBUtils.findZoneById(pool.getDataCenterId()).getName());
if (pool.getPoolType() != null) {
poolResponse.setType(pool.getPoolType().toString());
}
if (pool.getPodId() != null) {
poolResponse.setPodId(pool.getPodId());
HostPodVO pod = ApiDBUtils.findPodById(pool.getPodId());
if (pod != null) {
poolResponse.setPodName(pod.getName());
}
}
if (pool.getCreated() != null) {
poolResponse.setCreated(pool.getCreated());
}
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
long allocatedSize = ApiDBUtils.getStorageCapacitybyPool(pool.getId(), Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
poolResponse.setDiskSizeAllocated(allocatedSize);
if (stats != null) {
Long used = stats.getByteUsed();
poolResponse.setDiskSizeUsed(used);
}
if (pool.getClusterId() != null) {
ClusterVO cluster = ApiDBUtils.findClusterById(pool.getClusterId());
poolResponse.setClusterId(cluster.getId());
poolResponse.setClusterName(cluster.getName());
}
poolResponse.setTags(ApiDBUtils.getStoragePoolTags(pool.getId()));
poolResponse.setObjectName("storagepool");
return poolResponse;
}