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());
}
}
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;
}
Aggregations