Search in sources :

Example 1 with GetRouterMonitorResultsAnswer

use of com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method performRouterHealthChecks.

@Override
public Pair<Boolean, String> performRouterHealthChecks(long routerId) {
    DomainRouterVO router = _routerDao.findById(routerId);
    if (router == null) {
        throw new CloudRuntimeException("Unable to find router with id " + routerId);
    }
    if (!RouterHealthChecksEnabled.value()) {
        throw new CloudRuntimeException("Router health checks are not enabled for router: " + router);
    }
    s_logger.info("Running health check results for router " + router.getUuid());
    GetRouterMonitorResultsAnswer answer = null;
    String resultDetails = "";
    boolean success = true;
    // Step 1: Perform basic tests to check the connectivity and file system on router
    answer = performBasicTestsOnRouter(router);
    if (answer == null) {
        s_logger.debug("No results received for the basic tests on router: " + router);
        resultDetails = "Basic tests results unavailable";
        success = false;
    } else if (!answer.getResult()) {
        s_logger.debug("Basic tests failed on router: " + router);
        resultDetails = "Basic tests failed - " + answer.getMonitoringResults();
        success = false;
    } else {
        // Step 2: Update health check data on router and perform and retrieve health checks on router
        if (!updateRouterHealthChecksConfig(router)) {
            s_logger.warn("Unable to update health check config for fresh run successfully for router: " + router + ", so trying to fetch last result.");
            success = false;
            answer = fetchAndUpdateRouterHealthChecks(router, false);
        } else {
            s_logger.info("Successfully updated health check config for fresh run successfully for router: " + router);
            answer = fetchAndUpdateRouterHealthChecks(router, true);
        }
        if (answer == null) {
            resultDetails = "Failed to fetch and update health checks";
            success = false;
        } else if (!answer.getResult()) {
            resultDetails = "Get health checks failed - " + answer.getMonitoringResults();
            success = false;
        }
    }
    // Step 3: Update health checks values in database. We do this irrespective of new health check config.
    List<String> failingChecks = getFailingChecks(router, answer);
    handleFailingChecks(router, failingChecks);
    return new Pair<Boolean, String>(success, resultDetails);
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) DomainRouterVO(com.cloud.vm.DomainRouterVO) Pair(com.cloud.utils.Pair)

Example 2 with GetRouterMonitorResultsAnswer

use of com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer in project cloudstack by apache.

the class VirtualRoutingResource method execute.

private GetRouterMonitorResultsAnswer execute(GetRouterMonitorResultsCommand cmd) {
    String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
    Pair<Boolean, String> fileSystemTestResult = checkRouterFileSystem(routerIp);
    if (!fileSystemTestResult.first()) {
        return new GetRouterMonitorResultsAnswer(cmd, false, null, fileSystemTestResult.second());
    }
    if (cmd.shouldValidateBasicTestsOnly()) {
        // Basic tests (connectivity and file system checks) are already validated
        return new GetRouterMonitorResultsAnswer(cmd, true, null, "success");
    }
    String args = cmd.shouldPerformFreshChecks() ? "true" : "false";
    s_logger.info("Fetching health check result for " + routerIp + " and executing fresh checks: " + args);
    ExecutionResult result = _vrDeployer.executeInVR(routerIp, VRScripts.ROUTER_MONITOR_RESULTS, args);
    if (!result.isSuccess()) {
        s_logger.warn("Result of " + cmd + " failed with details: " + result.getDetails());
        return new GetRouterMonitorResultsAnswer(cmd, false, null, result.getDetails());
    }
    if (result.getDetails().isEmpty()) {
        s_logger.warn("Result of " + cmd + " received no details.");
        return new GetRouterMonitorResultsAnswer(cmd, false, null, "No results available.");
    }
    return parseLinesForHealthChecks(cmd, result.getDetails());
}
Also used : GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) ExecutionResult(com.cloud.utils.ExecutionResult)

Example 3 with GetRouterMonitorResultsAnswer

use of com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method performBasicTestsOnRouter.

private GetRouterMonitorResultsAnswer performBasicTestsOnRouter(DomainRouterVO router) {
    if (!RouterHealthChecksEnabled.value()) {
        return null;
    }
    String controlIP = _routerControlHelper.getRouterControlIp(router.getId());
    if (StringUtils.isNotBlank(controlIP) && !controlIP.equals("0.0.0.0")) {
        final GetRouterMonitorResultsCommand command = new GetRouterMonitorResultsCommand(false, true);
        command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlIP);
        command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
        try {
            final Answer answer = _agentMgr.easySend(router.getHostId(), command);
            if (answer == null) {
                s_logger.warn("Unable to fetch basic router test results data from router " + router.getHostName());
                return null;
            }
            if (answer instanceof GetRouterMonitorResultsAnswer) {
                return (GetRouterMonitorResultsAnswer) answer;
            } else {
                s_logger.warn("Unable to fetch basic router test results from router " + router.getHostName() + " Received answer " + answer.getDetails());
                return new GetRouterMonitorResultsAnswer(command, false, null, answer.getDetails());
            }
        } catch (final Exception e) {
            s_logger.warn("Error while performing basic tests on router: " + router.getInstanceName(), e);
            return null;
        }
    }
    return null;
}
Also used : GroupAnswer(com.cloud.agent.api.routing.GroupAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) GetRouterAlertsAnswer(com.cloud.agent.api.GetRouterAlertsAnswer) GetRouterMonitorResultsCommand(com.cloud.agent.api.routing.GetRouterMonitorResultsCommand) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) ConnectionException(com.cloud.exception.ConnectionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) JsonSyntaxException(com.google.gson.JsonSyntaxException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ParseException(java.text.ParseException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ConfigurationException(javax.naming.ConfigurationException)

Example 4 with GetRouterMonitorResultsAnswer

use of com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method fetchAndUpdateRouterHealthChecks.

private GetRouterMonitorResultsAnswer fetchAndUpdateRouterHealthChecks(DomainRouterVO router, boolean performFreshChecks) {
    if (!RouterHealthChecksEnabled.value()) {
        return null;
    }
    String controlIP = _routerControlHelper.getRouterControlIp(router.getId());
    if (StringUtils.isNotBlank(controlIP) && !controlIP.equals("0.0.0.0")) {
        final GetRouterMonitorResultsCommand command = new GetRouterMonitorResultsCommand(performFreshChecks, false);
        command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlIP);
        command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
        try {
            final Answer answer = _agentMgr.easySend(router.getHostId(), command);
            if (answer == null) {
                s_logger.warn("Unable to fetch monitoring results data from router " + router.getHostName());
                return null;
            }
            if (answer instanceof GetRouterMonitorResultsAnswer) {
                return (GetRouterMonitorResultsAnswer) answer;
            } else {
                s_logger.warn("Unable to fetch health checks results to router " + router.getHostName() + " Received answer " + answer.getDetails());
                return new GetRouterMonitorResultsAnswer(command, false, null, answer.getDetails());
            }
        } catch (final Exception e) {
            s_logger.warn("Error while collecting alerts from router: " + router.getInstanceName(), e);
            return null;
        }
    }
    return null;
}
Also used : GroupAnswer(com.cloud.agent.api.routing.GroupAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) GetRouterAlertsAnswer(com.cloud.agent.api.GetRouterAlertsAnswer) GetRouterMonitorResultsCommand(com.cloud.agent.api.routing.GetRouterMonitorResultsCommand) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) ConnectionException(com.cloud.exception.ConnectionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) JsonSyntaxException(com.google.gson.JsonSyntaxException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ParseException(java.text.ParseException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

GetRouterMonitorResultsAnswer (com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)2 Answer (com.cloud.agent.api.Answer)2 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)2 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)2 GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)2 GetRouterAlertsAnswer (com.cloud.agent.api.GetRouterAlertsAnswer)2 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)2 GetRouterMonitorResultsCommand (com.cloud.agent.api.routing.GetRouterMonitorResultsCommand)2 GroupAnswer (com.cloud.agent.api.routing.GroupAnswer)2 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 ConnectionException (com.cloud.exception.ConnectionException)2 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2