use of com.cloud.api.response.StoragePoolResponse in project cosmic by MissionCriticalCloud.
the class ViewResponseHelper method createStoragePoolForMigrationResponse.
public static List<StoragePoolResponse> createStoragePoolForMigrationResponse(final StoragePoolJoinVO... pools) {
final Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<>();
// Initialise the vrdatalist with the input data
for (final 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<>(vrDataList.values());
}
use of com.cloud.api.response.StoragePoolResponse in project cosmic by MissionCriticalCloud.
the class ViewResponseHelper method createStoragePoolResponse.
public static List<StoragePoolResponse> createStoragePoolResponse(final StoragePoolJoinVO... pools) {
final Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<>();
// Initialise the vrdatalist with the input data
for (final StoragePoolJoinVO vr : pools) {
StoragePoolResponse vrData = vrDataList.get(vr.getId());
if (vrData == null) {
// first time encountering this vm
vrData = ApiDBUtils.newStoragePoolResponse(vr);
} else {
// update tags
vrData = ApiDBUtils.fillStoragePoolDetails(vrData, vr);
}
vrDataList.put(vr.getId(), vrData);
}
return new ArrayList<>(vrDataList.values());
}
use of com.cloud.api.response.StoragePoolResponse in project cosmic by MissionCriticalCloud.
the class CreateStoragePoolCmd method execute.
@Override
public void execute() {
try {
final StoragePool result = _storageService.createPool(this);
if (result != null) {
final StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add storage pool");
}
} catch (final ResourceUnavailableException ex1) {
s_logger.warn("Exception: ", ex1);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
} catch (final ResourceInUseException ex2) {
s_logger.warn("Exception: ", ex2);
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex2.getMessage());
} catch (final UnknownHostException ex3) {
s_logger.warn("Exception: ", ex3);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex3.getMessage());
} catch (final Exception ex4) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex4.getMessage());
}
}
use of com.cloud.api.response.StoragePoolResponse in project cosmic by MissionCriticalCloud.
the class FindStoragePoolsForMigrationCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends StoragePool>, List<? extends StoragePool>> pools = _mgr.listStoragePoolsForMigrationOfVolume(getId());
final ListResponse<StoragePoolResponse> response = new ListResponse<>();
final List<StoragePoolResponse> poolResponses = new ArrayList<>();
final List<? extends StoragePool> allPools = pools.first();
final List<? extends StoragePool> suitablePoolList = pools.second();
for (final StoragePool pool : allPools) {
final StoragePoolResponse poolResponse = _responseGenerator.createStoragePoolForMigrationResponse(pool);
Boolean suitableForMigration = false;
for (final 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 com.cloud.api.response.StoragePoolResponse in project cosmic by MissionCriticalCloud.
the class UpdateStoragePoolCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final StoragePool result = _storageService.updateStoragePool(this);
if (result != null) {
final StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update storage pool");
}
}
Aggregations