Search in sources :

Example 1 with NetworkTO

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

the class LibvirtCheckOnHostCommandWrapper method execute.

@Override
public Answer execute(final CheckOnHostCommand command, final LibvirtComputingResource libvirtComputingResource) {
    final ExecutorService executors = Executors.newSingleThreadExecutor();
    final KVMHAMonitor monitor = libvirtComputingResource.getMonitor();
    final List<NfsStoragePool> pools = monitor.getStoragePools();
    final HostTO host = command.getHost();
    final NetworkTO privateNetwork = host.getPrivateNetwork();
    final KVMHAChecker ha = new KVMHAChecker(pools, privateNetwork.getIp());
    final Future<Boolean> future = executors.submit(ha);
    try {
        final Boolean result = future.get();
        if (result) {
            return new Answer(command, false, "Heart is still beating...");
        } else {
            return new Answer(command);
        }
    } catch (final InterruptedException e) {
        return new Answer(command, false, "can't get status of host:");
    } catch (final ExecutionException e) {
        return new Answer(command, false, "can't get status of host:");
    }
}
Also used : Answer(com.cloud.agent.api.Answer) KVMHAChecker(com.cloud.hypervisor.kvm.resource.KVMHAChecker) KVMHAMonitor(com.cloud.hypervisor.kvm.resource.KVMHAMonitor) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool) ExecutorService(java.util.concurrent.ExecutorService) HostTO(com.cloud.agent.api.to.HostTO) NetworkTO(com.cloud.agent.api.to.NetworkTO) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Answer (com.cloud.agent.api.Answer)1 HostTO (com.cloud.agent.api.to.HostTO)1 NetworkTO (com.cloud.agent.api.to.NetworkTO)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 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1