Search in sources :

Example 1 with CheckOnHostAnswer

use of com.cloud.legacymodel.communication.answer.CheckOnHostAnswer in project cosmic by MissionCriticalCloud.

the class XenServerInvestigator method isAgentAlive.

@Override
public HostStatus 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 : HostStatus.Down;
        }
    }
    return null;
}
Also used : CheckOnHostCommand(com.cloud.legacymodel.communication.command.CheckOnHostCommand) CheckOnHostAnswer(com.cloud.legacymodel.communication.answer.CheckOnHostAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CheckOnHostAnswer(com.cloud.legacymodel.communication.answer.CheckOnHostAnswer) HostVO(com.cloud.host.HostVO)

Aggregations

HostVO (com.cloud.host.HostVO)1 Answer (com.cloud.legacymodel.communication.answer.Answer)1 CheckOnHostAnswer (com.cloud.legacymodel.communication.answer.CheckOnHostAnswer)1 CheckOnHostCommand (com.cloud.legacymodel.communication.command.CheckOnHostCommand)1