Search in sources :

Example 6 with FenceAnswer

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

the class KVMFencer method fenceOff.

@Override
public Boolean fenceOff(final VirtualMachine vm, final Host host) {
    if (host.getHypervisorType() != HypervisorType.KVM) {
        s_logger.warn("Don't know how to fence non kvm hosts " + host.getHypervisorType());
        return null;
    }
    final List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
    final FenceCommand fence = new FenceCommand(vm, host);
    int i = 0;
    for (final HostVO h : hosts) {
        if (h.getHypervisorType() == HypervisorType.KVM) {
            if (h.getStatus() != HostStatus.Up) {
                continue;
            }
            i++;
            if (h.getId() == host.getId()) {
                continue;
            }
            final FenceAnswer answer;
            try {
                answer = (FenceAnswer) _agentMgr.send(h.getId(), fence);
            } catch (final AgentUnavailableException e) {
                s_logger.info("Moving on to the next host because " + h.toString() + " is unavailable");
                continue;
            } catch (final OperationTimedoutException e) {
                s_logger.info("Moving on to the next host because " + h.toString() + " is unavailable");
                continue;
            }
            if (answer != null && answer.getResult()) {
                return true;
            }
        }
    }
    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Unable to fence off host: " + host.getId(), "Fencing off host " + host.getId() + " did not succeed after asking " + i + " hosts. " + "Check Agent logs for more information.");
    s_logger.error("Unable to fence off " + vm.toString() + " on " + host.toString());
    return false;
}
Also used : FenceCommand(com.cloud.legacymodel.communication.command.FenceCommand) OperationTimedoutException(com.cloud.legacymodel.exceptions.OperationTimedoutException) AgentUnavailableException(com.cloud.legacymodel.exceptions.AgentUnavailableException) FenceAnswer(com.cloud.legacymodel.communication.answer.FenceAnswer) HostVO(com.cloud.host.HostVO)

Aggregations

FenceAnswer (com.cloud.legacymodel.communication.answer.FenceAnswer)6 HostVO (com.cloud.host.HostVO)3 FenceCommand (com.cloud.legacymodel.communication.command.FenceCommand)3 AgentUnavailableException (com.cloud.legacymodel.exceptions.AgentUnavailableException)2 OperationTimedoutException (com.cloud.legacymodel.exceptions.OperationTimedoutException)2 Connection (com.xensource.xenapi.Connection)2 XenAPIException (com.xensource.xenapi.Types.XenAPIException)2 VM (com.xensource.xenapi.VM)2 XmlRpcException (org.apache.xmlrpc.XmlRpcException)2 KvmHaChecker (com.cloud.agent.resource.kvm.ha.KvmHaChecker)1 KvmHaMonitor (com.cloud.agent.resource.kvm.ha.KvmHaMonitor)1 Answer (com.cloud.legacymodel.communication.answer.Answer)1 VirtualMachine (com.cloud.legacymodel.vm.VirtualMachine)1 VBD (com.xensource.xenapi.VBD)1 VDI (com.xensource.xenapi.VDI)1 HashSet (java.util.HashSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 Test (org.junit.Test)1