Search in sources :

Example 1 with FenceAnswer

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

the class OvmFencer method fenceOff.

@Override
public Boolean fenceOff(VirtualMachine vm, Host host) {
    if (host.getHypervisorType() != HypervisorType.Ovm) {
        s_logger.debug("Don't know how to fence non Ovm hosts " + host.getHypervisorType());
        return null;
    }
    List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
    FenceCommand fence = new FenceCommand(vm, host);
    for (HostVO h : hosts) {
        if (h.getHypervisorType() != HypervisorType.Ovm) {
            continue;
        }
        if (h.getStatus() != Status.Up) {
            continue;
        }
        if (h.getId() == host.getId()) {
            continue;
        }
        FenceAnswer answer;
        try {
            answer = (FenceAnswer) _agentMgr.send(h.getId(), fence);
        } catch (AgentUnavailableException e) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Moving on to the next host because " + h.toString() + " is unavailable");
            }
            continue;
        } catch (OperationTimedoutException e) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Moving on to the next host because " + h.toString() + " is unavailable");
            }
            continue;
        }
        if (answer != null && answer.getResult()) {
            return true;
        }
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Unable to fence off " + vm.toString() + " on " + host.toString());
    }
    return false;
}
Also used : FenceCommand(com.cloud.agent.api.FenceCommand) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) FenceAnswer(com.cloud.agent.api.FenceAnswer) HostVO(com.cloud.host.HostVO)

Example 2 with FenceAnswer

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

the class KVMFencer method fenceOff.

@Override
public Boolean fenceOff(VirtualMachine vm, Host host) {
    if (host.getHypervisorType() != HypervisorType.KVM && host.getHypervisorType() != HypervisorType.LXC) {
        s_logger.warn("Don't know how to fence non kvm hosts " + host.getHypervisorType());
        return null;
    }
    List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
    FenceCommand fence = new FenceCommand(vm, host);
    int i = 0;
    for (HostVO h : hosts) {
        if (h.getHypervisorType() == HypervisorType.KVM || h.getHypervisorType() == HypervisorType.LXC) {
            if (h.getStatus() != Status.Up) {
                continue;
            }
            i++;
            if (h.getId() == host.getId()) {
                continue;
            }
            FenceAnswer answer;
            try {
                answer = (FenceAnswer) _agentMgr.send(h.getId(), fence);
            } catch (AgentUnavailableException e) {
                s_logger.info("Moving on to the next host because " + h.toString() + " is unavailable");
                continue;
            } catch (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.agent.api.FenceCommand) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) FenceAnswer(com.cloud.agent.api.FenceAnswer) HostVO(com.cloud.host.HostVO)

Example 3 with FenceAnswer

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

the class Ovm3FenceBuilder method fenceOff.

@Override
public Boolean fenceOff(VirtualMachine vm, Host host) {
    if (host.getHypervisorType() != HypervisorType.Ovm3) {
        LOGGER.debug("Don't know how to fence non Ovm3 hosts " + host.getHypervisorType());
        return null;
    } else {
        LOGGER.debug("Fencing " + vm + " on host " + host + " with params: " + fenceParams);
    }
    List<HostVO> hosts = resourceMgr.listAllHostsInCluster(host.getClusterId());
    FenceCommand fence = new FenceCommand(vm, host);
    for (HostVO h : hosts) {
        if (h.getHypervisorType() == HypervisorType.Ovm3 && h.getStatus() == Status.Up && h.getId() != host.getId()) {
            FenceAnswer answer;
            try {
                answer = (FenceAnswer) agentMgr.send(h.getId(), fence);
            } catch (AgentUnavailableException | OperationTimedoutException e) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Moving on to the next host because " + h.toString() + " is unavailable", e);
                }
                continue;
            }
            if (answer != null && answer.getResult()) {
                return true;
            }
        }
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Unable to fence off " + vm.toString() + " on " + host.toString());
    }
    return false;
}
Also used : FenceCommand(com.cloud.agent.api.FenceCommand) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) FenceAnswer(com.cloud.agent.api.FenceAnswer) HostVO(com.cloud.host.HostVO)

Example 4 with FenceAnswer

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

the class XenServerFencer method fenceOff.

@Override
public Boolean fenceOff(VirtualMachine vm, Host host) {
    if (host.getHypervisorType() != HypervisorType.XenServer) {
        s_logger.debug("Don't know how to fence non XenServer hosts " + host.getHypervisorType());
        return null;
    }
    List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
    FenceCommand fence = new FenceCommand(vm, host);
    for (HostVO h : hosts) {
        if (h.getHypervisorType() == HypervisorType.XenServer) {
            if (h.getStatus() != Status.Up) {
                continue;
            }
            if (h.getId() == host.getId()) {
                continue;
            }
            FenceAnswer answer;
            try {
                Answer ans = _agentMgr.send(h.getId(), fence);
                if (!(ans instanceof FenceAnswer)) {
                    s_logger.debug("Answer is not fenceanswer.  Result = " + ans.getResult() + "; Details = " + ans.getDetails());
                    continue;
                }
                answer = (FenceAnswer) ans;
            } catch (AgentUnavailableException e) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Moving on to the next host because " + h.toString() + " is unavailable");
                }
                continue;
            } catch (OperationTimedoutException e) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Moving on to the next host because " + h.toString() + " is unavailable");
                }
                continue;
            }
            if (answer != null && answer.getResult()) {
                return true;
            }
        }
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Unable to fence off " + vm.toString() + " on " + host.toString());
    }
    return false;
}
Also used : FenceAnswer(com.cloud.agent.api.FenceAnswer) Answer(com.cloud.agent.api.Answer) FenceCommand(com.cloud.agent.api.FenceCommand) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) FenceAnswer(com.cloud.agent.api.FenceAnswer) HostVO(com.cloud.host.HostVO)

Example 5 with FenceAnswer

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

the class SimulatorFencer method fenceOff.

@Override
public Boolean fenceOff(VirtualMachine vm, Host host) {
    if (host.getHypervisorType() != HypervisorType.Simulator) {
        s_logger.debug("Don't know how to fence non simulator hosts " + host.getHypervisorType());
        return null;
    }
    List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
    FenceCommand fence = new FenceCommand(vm, host);
    for (HostVO h : hosts) {
        if (h.getHypervisorType() == HypervisorType.Simulator) {
            if (h.getStatus() != Status.Up) {
                continue;
            }
            if (h.getId() == host.getId()) {
                continue;
            }
            FenceAnswer answer = null;
            try {
                answer = (FenceAnswer) _agentMgr.send(h.getId(), fence);
            } catch (AgentUnavailableException e) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Moving on to the next host because " + h.toString() + " is unavailable");
                }
                continue;
            } catch (OperationTimedoutException e) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Moving on to the next host because " + h.toString() + " is unavailable");
                }
                continue;
            }
            if (answer != null && answer.getResult()) {
                return true;
            }
        }
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Unable to fence off " + vm.toString() + " on " + host.toString());
    }
    return false;
}
Also used : FenceCommand(com.cloud.agent.api.FenceCommand) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) FenceAnswer(com.cloud.agent.api.FenceAnswer) HostVO(com.cloud.host.HostVO)

Aggregations

FenceAnswer (com.cloud.agent.api.FenceAnswer)10 FenceCommand (com.cloud.agent.api.FenceCommand)6 HostVO (com.cloud.host.HostVO)6 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)5 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)5 Connection (com.xensource.xenapi.Connection)2 XenAPIException (com.xensource.xenapi.Types.XenAPIException)2 VM (com.xensource.xenapi.VM)2 ExecutionException (java.util.concurrent.ExecutionException)2 ExecutorService (java.util.concurrent.ExecutorService)2 XmlRpcException (org.apache.xmlrpc.XmlRpcException)2 Answer (com.cloud.agent.api.Answer)1 NfsStoragePool (com.cloud.agent.resource.computing.KVMHABase.NfsStoragePool)1 NfsStoragePool (com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool)1 KVMHAChecker (com.cloud.hypervisor.kvm.resource.KVMHAChecker)1 KVMHAMonitor (com.cloud.hypervisor.kvm.resource.KVMHAMonitor)1 VirtualMachine (com.cloud.vm.VirtualMachine)1 VBD (com.xensource.xenapi.VBD)1 VDI (com.xensource.xenapi.VDI)1 HashSet (java.util.HashSet)1