Search in sources :

Example 1 with RouterHealthCheckResultsListResponse

use of org.apache.cloudstack.api.response.RouterHealthCheckResultsListResponse 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)

Aggregations

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