Search in sources :

Example 1 with Common

use of com.cloud.hypervisor.ovm3.objects.Common 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 Common

use of com.cloud.hypervisor.ovm3.objects.Common in project cloudstack by apache.

the class Ovm3HypervisorResource method getCurrentStatus.

@Override
public PingCommand getCurrentStatus(long id) {
    try {
        /* feels useless somehow */
        Common test = new Common(c);
        String ping = "put";
        String pong = test.echo(ping);
        if (pong.contains(ping)) {
            hypervisorsupport.syncState();
            CloudstackPlugin cSp = new CloudstackPlugin(c);
            if (!cSp.dom0CheckStorageHealthCheck(configuration.getAgentScriptsDir(), configuration.getAgentCheckStorageScript(), configuration.getCsHostGuid(), configuration.getAgentStorageCheckTimeout(), configuration.getAgentStorageCheckInterval()) && !cSp.dom0CheckStorageHealthCheck()) {
                LOGGER.error("Storage health check not running on " + configuration.getAgentHostname());
            } else if (cSp.dom0CheckStorageHealthCheck()) {
                LOGGER.error("Storage health check started on " + configuration.getAgentHostname());
            } else {
                LOGGER.debug("Storage health check running on " + configuration.getAgentHostname());
            }
            return new PingRoutingCommand(getType(), id, hypervisorsupport.hostVmStateReport());
        } else {
            LOGGER.debug("Agent did not respond correctly: " + ping + " but got " + pong);
        }
    } catch (Ovm3ResourceException | NullPointerException e) {
        LOGGER.debug("Check agent status failed", e);
        return null;
    }
    return null;
}
Also used : PingRoutingCommand(com.cloud.agent.api.PingRoutingCommand) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin) Common(com.cloud.hypervisor.ovm3.objects.Common)

Aggregations

Common (com.cloud.hypervisor.ovm3.objects.Common)2 Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)2 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)1 PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)1 CloudstackPlugin (com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)1