use of com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testResizeVolumeCommandException2.
@Test
public void testResizeVolumeCommandException2() {
final String path = "nfs:/127.0.0.1/storage/secondary";
final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class);
final Long currentSize = 100l;
final Long newSize = 200l;
final boolean shrinkOk = false;
final String vmInstance = "Test";
final ResizeVolumeCommand command = new ResizeVolumeCommand(path, pool, currentSize, newSize, shrinkOk, vmInstance);
final KvmStoragePoolManager storagePoolMgr = Mockito.mock(KvmStoragePoolManager.class);
final KvmStoragePool storagePool = Mockito.mock(KvmStoragePool.class);
when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
when(storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(storagePool);
when(storagePool.getPhysicalDisk(path)).thenThrow(CloudRuntimeException.class);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
}
use of com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testCheckSshCommand.
@Test
public void testCheckSshCommand() {
final String instanceName = "Test";
final String ip = "127.0.0.1";
final int port = 22;
final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port);
final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class);
final String privateIp = command.getIp();
final int cmdPort = command.getPort();
when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource);
when(virtRouterResource.connect(privateIp, cmdPort)).thenReturn(true);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getVirtRouterResource();
verify(virtRouterResource, times(1)).connect(privateIp, cmdPort);
}
use of com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testCheckSshCommandFailure.
@Test
public void testCheckSshCommandFailure() {
final String instanceName = "Test";
final String ip = "127.0.0.1";
final int port = 22;
final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port);
final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class);
final String privateIp = command.getIp();
final int cmdPort = command.getPort();
when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource);
when(virtRouterResource.connect(privateIp, cmdPort)).thenReturn(false);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertFalse(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getVirtRouterResource();
verify(virtRouterResource, times(1)).connect(privateIp, cmdPort);
}
use of com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testCreateStoragePoolCommand.
@Test
public void testCreateStoragePoolCommand() {
final StoragePool pool = Mockito.mock(StoragePool.class);
final CreateStoragePoolCommand command = new CreateStoragePoolCommand(true, pool);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
}
use of com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testAttachIsoCommand.
@Test
public void testAttachIsoCommand() {
final Connect conn = Mockito.mock(Connect.class);
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
final String vmName = "Test";
final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true);
when(this.libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
try {
when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn);
} catch (final LibvirtException e) {
fail(e.getMessage());
}
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
try {
verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName);
} catch (final LibvirtException e) {
fail(e.getMessage());
}
}
Aggregations