Search in sources :

Example 31 with LibvirtRequestWrapper

use of com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper in project cloudstack by apache.

the class LibvirtComputingResourceTest method testReadyCommand.

@Test
public void testReadyCommand() {
    final ReadyCommand command = new ReadyCommand(1l);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());
}
Also used : AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) ReadyCommand(com.cloud.agent.api.ReadyCommand) Test(org.junit.Test)

Example 32 with LibvirtRequestWrapper

use of com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper in project cloudstack by apache.

the class LibvirtComputingResourceTest method testDeleteStoragePoolCommand.

@Test
public void testDeleteStoragePoolCommand() {
    final StoragePool storagePool = Mockito.mock(StoragePool.class);
    final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class);
    final DeleteStoragePoolCommand command = new DeleteStoragePoolCommand(storagePool);
    final StorageFilerTO pool = command.getPool();
    when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
    when(storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid())).thenReturn(true);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(libvirtComputingResource, times(1)).getStoragePoolMgr();
    verify(storagePoolMgr, times(1)).deleteStoragePool(pool.getType(), pool.getUuid());
}
Also used : AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) KVMStoragePoolManager(com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) KVMStoragePool(com.cloud.hypervisor.kvm.storage.KVMStoragePool) StoragePool(com.cloud.storage.StoragePool) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) Test(org.junit.Test)

Example 33 with LibvirtRequestWrapper

use of com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper in project cloudstack by apache.

the class LibvirtComputingResourceTest method testOvsCreateTunnelCommandFailure2.

@SuppressWarnings("unchecked")
@Test
public void testOvsCreateTunnelCommandFailure2() {
    final String remoteIp = "127.0.0.1";
    final Integer key = 1;
    final Long from = 1l;
    final Long to = 2l;
    final long networkId = 1l;
    final String fromIp = "127.0.0.1";
    final String networkName = "eth";
    final String networkUuid = "8edb1156-a851-4914-afc6-468ee52ac861";
    final OvsCreateTunnelCommand command = new OvsCreateTunnelCommand(remoteIp, key, from, to, networkId, fromIp, networkName, networkUuid);
    final String bridge = command.getNetworkName();
    when(libvirtComputingResource.findOrCreateTunnelNetwork(bridge)).thenReturn(true);
    when(libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getFrom(), command.getNetworkName())).thenThrow(Exception.class);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(bridge);
    verify(libvirtComputingResource, times(1)).configureTunnelNetwork(command.getNetworkId(), command.getFrom(), command.getNetworkName());
}
Also used : AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) OvsCreateTunnelCommand(com.cloud.agent.api.OvsCreateTunnelCommand) Test(org.junit.Test)

Example 34 with LibvirtRequestWrapper

use of com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper in project cloudstack by apache.

the class LibvirtComputingResourceTest method testDeleteStoragePoolCommandException.

@SuppressWarnings("unchecked")
@Test
public void testDeleteStoragePoolCommandException() {
    final StoragePool storagePool = Mockito.mock(StoragePool.class);
    final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class);
    final DeleteStoragePoolCommand command = new DeleteStoragePoolCommand(storagePool);
    final StorageFilerTO pool = command.getPool();
    when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
    when(storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid())).thenThrow(CloudRuntimeException.class);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(libvirtComputingResource, times(1)).getStoragePoolMgr();
    verify(storagePoolMgr, times(1)).deleteStoragePool(pool.getType(), pool.getUuid());
}
Also used : AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) KVMStoragePoolManager(com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) KVMStoragePool(com.cloud.hypervisor.kvm.storage.KVMStoragePool) StoragePool(com.cloud.storage.StoragePool) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) Test(org.junit.Test)

Example 35 with LibvirtRequestWrapper

use of com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper in project cloudstack by apache.

the class LibvirtComputingResourceTest method testModifySshKeysCommand.

@Test
public void testModifySshKeysCommand() {
    final ModifySshKeysCommand command = new ModifySshKeysCommand("", "");
    final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
    when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
    when(libvirtUtilitiesHelper.retrieveSshKeysPath()).thenReturn("/path/keys");
    when(libvirtUtilitiesHelper.retrieveSshPubKeyPath()).thenReturn("/path/pub/keys");
    when(libvirtUtilitiesHelper.retrieveSshPrvKeyPath()).thenReturn("/path/pvt/keys");
    when(libvirtComputingResource.getTimeout()).thenReturn(Duration.ZERO);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(libvirtComputingResource, times(1)).getTimeout();
}
Also used : AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) ModifySshKeysCommand(com.cloud.agent.api.ModifySshKeysCommand) LibvirtUtilitiesHelper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper) Test(org.junit.Test)

Aggregations

Answer (com.cloud.agent.api.Answer)135 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)135 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)135 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)135 Test (org.junit.Test)135 LibvirtUtilitiesHelper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper)68 LibvirtException (org.libvirt.LibvirtException)55 KVMStoragePoolManager (com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager)44 Connect (org.libvirt.Connect)39 KVMStoragePool (com.cloud.hypervisor.kvm.storage.KVMStoragePool)36 NfsStoragePool (com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool)29 StoragePool (com.cloud.storage.StoragePool)28 ArrayList (java.util.ArrayList)21 KVMPhysicalDisk (com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk)20 NicTO (com.cloud.agent.api.to.NicTO)19 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)16 VirtualMachineTO (com.cloud.agent.api.to.VirtualMachineTO)13 InternalErrorException (com.cloud.exception.InternalErrorException)13 Domain (org.libvirt.Domain)11 InterfaceDef (com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef)10