Search in sources :

Example 1 with NfsStoragePool

use of com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool in project cloudstack by apache.

the class LibvirtComputingResourceTest method testFenceCommand.

@Test
public void testFenceCommand() {
    final VirtualMachine vm = Mockito.mock(VirtualMachine.class);
    ;
    final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class);
    final FenceCommand command = new FenceCommand(vm, host);
    final KVMHAMonitor monitor = Mockito.mock(KVMHAMonitor.class);
    final NfsStoragePool storagePool = Mockito.mock(NfsStoragePool.class);
    final List<NfsStoragePool> pools = new ArrayList<NfsStoragePool>();
    pools.add(storagePool);
    when(libvirtComputingResource.getMonitor()).thenReturn(monitor);
    when(monitor.getStoragePools()).thenReturn(pools);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(libvirtComputingResource, times(1)).getMonitor();
    verify(monitor, times(1)).getStoragePools();
}
Also used : UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) FenceCommand(com.cloud.agent.api.FenceCommand) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool) ArrayList(java.util.ArrayList) VirtualMachine(com.cloud.vm.VirtualMachine) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with NfsStoragePool

use of com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testFenceCommand.

@Test
public void testFenceCommand() {
    final VirtualMachine vm = Mockito.mock(VirtualMachine.class);
    final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class);
    final FenceCommand command = new FenceCommand(vm, host);
    final KvmHaMonitor monitor = Mockito.mock(KvmHaMonitor.class);
    final NfsStoragePool storagePool = Mockito.mock(NfsStoragePool.class);
    final List<NfsStoragePool> pools = new ArrayList<>();
    pools.add(storagePool);
    when(libvirtComputingResource.getMonitor()).thenReturn(monitor);
    when(monitor.getStoragePools()).thenReturn(pools);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(libvirtComputingResource, times(1)).getMonitor();
    verify(monitor, times(1)).getStoragePools();
}
Also used : Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AttachAnswer(com.cloud.storage.command.AttachAnswer) FenceCommand(com.cloud.agent.api.FenceCommand) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool) ArrayList(java.util.ArrayList) VirtualMachine(com.cloud.vm.VirtualMachine) Test(org.junit.Test)

Example 3 with NfsStoragePool

use of com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool in project cosmic by MissionCriticalCloud.

the class LibvirtFenceCommandWrapper method execute.

@Override
public Answer execute(final FenceCommand command, final LibvirtComputingResource libvirtComputingResource) {
    final ExecutorService executors = Executors.newSingleThreadExecutor();
    final KvmHaMonitor monitor = libvirtComputingResource.getMonitor();
    final List<NfsStoragePool> pools = monitor.getStoragePools();
    /**
     * We can only safely fence off hosts when we use NFS On NFS primary storage pools hosts continuesly write a
     * heartbeat. Disable Fencing Off for hosts without NFS
     */
    if (pools.size() == 0) {
        final String logline = "No NFS storage pools found. No way to safely fence " + command.getVmName() + " on host " + command.getHostGuid();
        s_logger.warn(logline);
        return new FenceAnswer(command, false, logline);
    }
    final KvmHaChecker ha = new KvmHaChecker(pools, command.getHostIp());
    final Future<Boolean> future = executors.submit(ha);
    try {
        final Boolean result = future.get();
        if (result) {
            return new FenceAnswer(command, false, "Heart is still beating...");
        } else {
            return new FenceAnswer(command);
        }
    } catch (final InterruptedException e) {
        s_logger.warn("Unable to fence", e);
        return new FenceAnswer(command, false, e.getMessage());
    } catch (final ExecutionException e) {
        s_logger.warn("Unable to fence", e);
        return new FenceAnswer(command, false, e.getMessage());
    }
}
Also used : NfsStoragePool(com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool) ExecutorService(java.util.concurrent.ExecutorService) KvmHaChecker(com.cloud.hypervisor.kvm.resource.KvmHaChecker) KvmHaMonitor(com.cloud.hypervisor.kvm.resource.KvmHaMonitor) FenceAnswer(com.cloud.agent.api.FenceAnswer) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with NfsStoragePool

use of com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool 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<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) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool) ExecutorService(java.util.concurrent.ExecutorService) KvmHaChecker(com.cloud.hypervisor.kvm.resource.KvmHaChecker) KvmHaMonitor(com.cloud.hypervisor.kvm.resource.KvmHaMonitor) HostTO(com.cloud.agent.api.to.HostTO) NetworkTO(com.cloud.agent.api.to.NetworkTO) ExecutionException(java.util.concurrent.ExecutionException)

Example 5 with NfsStoragePool

use of com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool in project cloudstack by apache.

the class LibvirtCheckVMActivityOnStoragePoolCommandWrapper method execute.

@Override
public Answer execute(final CheckVMActivityOnStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) {
    final ExecutorService executors = Executors.newSingleThreadExecutor();
    final KVMHAMonitor monitor = libvirtComputingResource.getMonitor();
    final StorageFilerTO pool = command.getPool();
    if (Storage.StoragePoolType.NetworkFilesystem == pool.getType()) {
        final NfsStoragePool nfspool = monitor.getStoragePool(pool.getUuid());
        final KVMHAVMActivityChecker ha = new KVMHAVMActivityChecker(nfspool, command.getHost().getPrivateNetwork().getIp(), command.getVolumeList(), libvirtComputingResource.getVmActivityCheckPath(), command.getSuspectTimeInSeconds());
        final Future<Boolean> future = executors.submit(ha);
        try {
            final Boolean result = future.get();
            if (result) {
                return new Answer(command, false, "VMHA disk activity detected ...");
            } else {
                return new Answer(command);
            }
        } catch (InterruptedException e) {
            return new Answer(command, false, "CheckVMActivityOnStoragePoolCommand: can't get status of host: InterruptedException");
        } catch (ExecutionException e) {
            return new Answer(command, false, "CheckVMActivityOnStoragePoolCommand: can't get status of host: ExecutionException");
        }
    }
    return new Answer(command, false, "Unsupported Storage");
}
Also used : Answer(com.cloud.agent.api.Answer) KVMHAMonitor(com.cloud.hypervisor.kvm.resource.KVMHAMonitor) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool) ExecutorService(java.util.concurrent.ExecutorService) KVMHAVMActivityChecker(com.cloud.hypervisor.kvm.resource.KVMHAVMActivityChecker) ExecutionException(java.util.concurrent.ExecutionException) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO)

Aggregations

Answer (com.cloud.agent.api.Answer)5 ExecutionException (java.util.concurrent.ExecutionException)5 ExecutorService (java.util.concurrent.ExecutorService)5 NfsStoragePool (com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool)4 KVMHAMonitor (com.cloud.hypervisor.kvm.resource.KVMHAMonitor)3 NfsStoragePool (com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool)3 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)2 FenceAnswer (com.cloud.agent.api.FenceAnswer)2 FenceCommand (com.cloud.agent.api.FenceCommand)2 HostTO (com.cloud.agent.api.to.HostTO)2 NetworkTO (com.cloud.agent.api.to.NetworkTO)2 KVMHAChecker (com.cloud.hypervisor.kvm.resource.KVMHAChecker)2 KvmHaChecker (com.cloud.hypervisor.kvm.resource.KvmHaChecker)2 KvmHaMonitor (com.cloud.hypervisor.kvm.resource.KvmHaMonitor)2 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)2 VirtualMachine (com.cloud.vm.VirtualMachine)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 UnsupportedAnswer (com.cloud.agent.api.UnsupportedAnswer)1 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)1