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());
}
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());
}
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());
}
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());
}
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();
}
Aggregations