Search in sources :

Example 1 with NetworkTO

use of com.cloud.legacymodel.to.NetworkTO in project cosmic by MissionCriticalCloud.

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<KvmHaBase.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.legacymodel.communication.answer.Answer) ExecutorService(java.util.concurrent.ExecutorService) KvmHaChecker(com.cloud.agent.resource.kvm.ha.KvmHaChecker) KvmHaMonitor(com.cloud.agent.resource.kvm.ha.KvmHaMonitor) HostTO(com.cloud.legacymodel.to.HostTO) NetworkTO(com.cloud.legacymodel.to.NetworkTO) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

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