Search in sources :

Example 11 with StoragePoolResponse

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

Example 12 with StoragePoolResponse

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

Example 13 with StoragePoolResponse

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());
    }
}
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) ServerApiException(com.cloud.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) UnknownHostException(java.net.UnknownHostException) ResourceInUseException(com.cloud.exception.ResourceInUseException)

Example 14 with StoragePoolResponse

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

Example 15 with StoragePoolResponse

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

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