Search in sources :

Example 1 with CheckOnHostAnswer

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

the class Ovm3HypervisorSupport method execute.

public CheckOnHostAnswer execute(CheckOnHostCommand cmd) {
    LOGGER.debug("CheckOnHostCommand");
    CloudstackPlugin csp = new CloudstackPlugin(c);
    try {
        Boolean alive = csp.dom0CheckStorageHealth(config.getAgentScriptsDir(), config.getAgentCheckStorageScript(), cmd.getHost().getGuid(), config.getAgentStorageCheckTimeout());
        String msg = "";
        if (alive == null) {
            msg = "storage check failed for " + cmd.getHost().getGuid();
        } else if (alive) {
            msg = "storage check ok for " + cmd.getHost().getGuid();
        } else {
            msg = "storage dead for " + cmd.getHost().getGuid();
        }
        LOGGER.debug(msg);
        return new CheckOnHostAnswer(cmd, alive, msg);
    } catch (Ovm3ResourceException e) {
        return new CheckOnHostAnswer(cmd, false, "Error while checking storage for " + cmd.getHost().getGuid() + ": " + e.getMessage());
    }
}
Also used : Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CheckOnHostAnswer(com.cloud.agent.api.CheckOnHostAnswer) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)

Example 2 with CheckOnHostAnswer

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

the class XenServerInvestigator method isAgentAlive.

@Override
public Status isAgentAlive(Host agent) {
    if (agent.getHypervisorType() != HypervisorType.XenServer) {
        return null;
    }
    CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
    List<HostVO> neighbors = _resourceMgr.listAllHostsInCluster(agent.getClusterId());
    for (HostVO neighbor : neighbors) {
        if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.XenServer) {
            continue;
        }
        Answer answer = _agentMgr.easySend(neighbor.getId(), cmd);
        if (answer != null && answer.getResult()) {
            CheckOnHostAnswer ans = (CheckOnHostAnswer) answer;
            if (!ans.isDetermined()) {
                s_logger.debug("Host " + neighbor + " couldn't determine the status of " + agent);
                continue;
            }
            // even it returns true, that means host is up, but XAPI may not work
            return ans.isAlive() ? null : Status.Down;
        }
    }
    return null;
}
Also used : CheckOnHostCommand(com.cloud.agent.api.CheckOnHostCommand) CheckOnHostAnswer(com.cloud.agent.api.CheckOnHostAnswer) Answer(com.cloud.agent.api.Answer) CheckOnHostAnswer(com.cloud.agent.api.CheckOnHostAnswer) HostVO(com.cloud.host.HostVO)

Example 3 with CheckOnHostAnswer

use of com.cloud.agent.api.CheckOnHostAnswer in project cosmic by MissionCriticalCloud.

the class XenServerInvestigator method isAgentAlive.

@Override
public Status isAgentAlive(final Host agent) {
    if (agent.getHypervisorType() != HypervisorType.XenServer) {
        return null;
    }
    final CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
    final List<HostVO> neighbors = _resourceMgr.listAllHostsInCluster(agent.getClusterId());
    for (final HostVO neighbor : neighbors) {
        if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.XenServer) {
            continue;
        }
        final Answer answer = _agentMgr.easySend(neighbor.getId(), cmd);
        if (answer != null && answer.getResult()) {
            final CheckOnHostAnswer ans = (CheckOnHostAnswer) answer;
            if (!ans.isDetermined()) {
                s_logger.debug("Host " + neighbor + " couldn't determine the status of " + agent);
                continue;
            }
            // even it returns true, that means host is up, but XAPI may not work
            return ans.isAlive() ? null : Status.Down;
        }
    }
    return null;
}
Also used : CheckOnHostCommand(com.cloud.agent.api.CheckOnHostCommand) CheckOnHostAnswer(com.cloud.agent.api.CheckOnHostAnswer) Answer(com.cloud.agent.api.Answer) CheckOnHostAnswer(com.cloud.agent.api.CheckOnHostAnswer) HostVO(com.cloud.host.HostVO)

Aggregations

CheckOnHostAnswer (com.cloud.agent.api.CheckOnHostAnswer)3 Answer (com.cloud.agent.api.Answer)2 CheckOnHostCommand (com.cloud.agent.api.CheckOnHostCommand)2 HostVO (com.cloud.host.HostVO)2 CloudstackPlugin (com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)1 Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)1