Search in sources :

Example 1 with CheckHealthAnswer

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

the class Ovm3HypervisorSupport method execute.

/**
     * CheckHealthAnwer: Check the health of an agent on the hypervisor.
     * TODO: should elaborate here with checks...
     *
     * @param cmd
     * @return
     */
public CheckHealthAnswer execute(CheckHealthCommand cmd) {
    Common test = new Common(c);
    String ping = "put";
    String pong;
    try {
        pong = test.echo(ping);
    } catch (Ovm3ResourceException e) {
        LOGGER.debug("CheckHealth went wrong: " + config.getAgentHostname() + ", " + e.getMessage(), e);
        return new CheckHealthAnswer(cmd, false);
    }
    if (ping.contentEquals(pong)) {
        return new CheckHealthAnswer(cmd, true);
    }
    LOGGER.debug("CheckHealth did not receive " + ping + " but got " + pong + " from " + config.getAgentHostname());
    return new CheckHealthAnswer(cmd, false);
}
Also used : CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) Common(com.cloud.hypervisor.ovm3.objects.Common)

Example 2 with CheckHealthAnswer

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

the class NiciraCheckHealthCommandWrapper method execute.

@Override
public Answer execute(final CheckHealthCommand command, final NiciraNvpResource serverResource) {
    final NiciraNvpApi niciraNvpApi = serverResource.getNiciraNvpApi();
    boolean healthy = true;
    try {
        final ControlClusterStatus clusterStatus = niciraNvpApi.getControlClusterStatus();
        final String status = clusterStatus.getClusterStatus();
        if (clusterIsUnstable(status)) {
            s_logger.warn("Control cluster is not stable. Current status is " + status);
            healthy = false;
        }
    } catch (final NiciraNvpApiException e) {
        s_logger.error("Exception caught while checking control cluster status during health check", e);
        healthy = false;
    }
    return new CheckHealthAnswer(command, healthy);
}
Also used : ControlClusterStatus(com.cloud.network.nicira.ControlClusterStatus) CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) NiciraNvpApi(com.cloud.network.nicira.NiciraNvpApi) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException)

Aggregations

CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)2 Common (com.cloud.hypervisor.ovm3.objects.Common)1 Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)1 ControlClusterStatus (com.cloud.network.nicira.ControlClusterStatus)1 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)1 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)1