Search in sources :

Example 1 with RouterHealthCheckResultResponse

use of org.apache.cloudstack.api.response.RouterHealthCheckResultResponse in project cloudstack by apache.

the class GetRouterHealthCheckResultsCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InvalidParameterValueException, ServerApiException {
    CallContext.current().setEventDetails("Router Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getRouterId()));
    VirtualRouter router = _routerService.findRouter(getRouterId());
    if (router == null || router.getRole() != VirtualRouter.Role.VIRTUAL_ROUTER) {
        throw new InvalidParameterValueException("Can't find router by routerId");
    }
    try {
        List<RouterHealthCheckResultResponse> healthChecks = _queryService.listRouterHealthChecks(this);
        RouterHealthCheckResultsListResponse routerResponse = new RouterHealthCheckResultsListResponse();
        routerResponse.setRouterId(router.getUuid());
        routerResponse.setHealthChecks(healthChecks);
        routerResponse.setObjectName("routerhealthchecks");
        routerResponse.setResponseName(getCommandName());
        setResponseObject(routerResponse);
    } catch (CloudRuntimeException ex) {
        ex.printStackTrace();
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to get health check results due to: " + ex.getLocalizedMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) RouterHealthCheckResultsListResponse(org.apache.cloudstack.api.response.RouterHealthCheckResultsListResponse) VirtualRouter(com.cloud.network.router.VirtualRouter) RouterHealthCheckResultResponse(org.apache.cloudstack.api.response.RouterHealthCheckResultResponse)

Example 2 with RouterHealthCheckResultResponse

use of org.apache.cloudstack.api.response.RouterHealthCheckResultResponse in project cloudstack by apache.

the class ApiResponseHelper method createHealthCheckResponse.

@Override
public List<RouterHealthCheckResultResponse> createHealthCheckResponse(VirtualMachine router, List<RouterHealthCheckResult> healthCheckResults) {
    List<RouterHealthCheckResultResponse> responses = new ArrayList<>(healthCheckResults.size());
    for (RouterHealthCheckResult hcResult : healthCheckResults) {
        RouterHealthCheckResultResponse healthCheckResponse = new RouterHealthCheckResultResponse();
        healthCheckResponse.setObjectName("routerhealthchecks");
        healthCheckResponse.setCheckName(hcResult.getCheckName());
        healthCheckResponse.setCheckType(hcResult.getCheckType());
        healthCheckResponse.setResult(hcResult.getCheckResult());
        healthCheckResponse.setLastUpdated(hcResult.getLastUpdateTime());
        healthCheckResponse.setDetails(hcResult.getParsedCheckDetails());
        responses.add(healthCheckResponse);
    }
    return responses;
}
Also used : ArrayList(java.util.ArrayList) RouterHealthCheckResultResponse(org.apache.cloudstack.api.response.RouterHealthCheckResultResponse) RouterHealthCheckResult(com.cloud.network.RouterHealthCheckResult)

Aggregations

RouterHealthCheckResultResponse (org.apache.cloudstack.api.response.RouterHealthCheckResultResponse)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 RouterHealthCheckResult (com.cloud.network.RouterHealthCheckResult)1 VirtualRouter (com.cloud.network.router.VirtualRouter)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ArrayList (java.util.ArrayList)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 RouterHealthCheckResultsListResponse (org.apache.cloudstack.api.response.RouterHealthCheckResultsListResponse)1