Search in sources :

Example 1 with MockResponse

use of com.cloud.api.response.MockResponse in project cloudstack by apache.

the class ConfigureSimulatorCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    if (hostId != null && jsonResponse != null) {
        jsonResponse = jsonResponse.replace("\"hostId\":0", "\"hostId\":" + hostId);
    }
    Long id = _simMgr.configureSimulator(zoneId, podId, clusterId, hostId, command, values, count, jsonResponse);
    if (id == null) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure simulator");
    }
    MockConfigurationVO config = _simMgr.querySimulatorMock(id);
    if (config == null) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to query simulator mock");
    }
    MockResponse response = new MockResponse();
    response.setId(config.getId());
    response.setZoneId(config.getDataCenterId());
    response.setPodId(config.getPodId());
    response.setClusterId(config.getClusterId());
    response.setHostId(config.getHostId());
    response.setName(config.getName());
    response.setCount(config.getCount());
    response.setResponseName("simulatormock");
    this.setResponseObject(response);
}
Also used : MockConfigurationVO(com.cloud.simulator.MockConfigurationVO) MockResponse(com.cloud.api.response.MockResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 2 with MockResponse

use of com.cloud.api.response.MockResponse in project cloudstack by apache.

the class QuerySimulatorMockCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    MockConfigurationVO config = _simMgr.querySimulatorMock(id);
    if (config == null) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to query mock");
    }
    MockResponse response = new MockResponse();
    response.setId(config.getId());
    response.setZoneId(config.getDataCenterId());
    response.setPodId(config.getPodId());
    response.setClusterId(config.getClusterId());
    response.setHostId(config.getHostId());
    response.setName(config.getName());
    response.setCount(config.getCount());
    response.setResponseName("simulatormock");
    this.setResponseObject(response);
}
Also used : MockConfigurationVO(com.cloud.simulator.MockConfigurationVO) MockResponse(com.cloud.api.response.MockResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Aggregations

MockResponse (com.cloud.api.response.MockResponse)2 MockConfigurationVO (com.cloud.simulator.MockConfigurationVO)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2