Search in sources :

Example 56 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class RunVmCommandTest method auditLogRunStatelessVmCreateImages.

@Test
public void auditLogRunStatelessVmCreateImages() {
    doReturn(RunVmFlow.CREATE_STATELESS_IMAGES).when(command).getFlow();
    command.setVm(new VM());
    command.setInternalExecution(false);
    command.setSucceeded(true);
    command.setActionReturnValue(VMStatus.Down);
    doReturn(false).when(command).isStatelessSnapshotExistsForVm();
    assertEquals(AuditLogType.USER_INITIATED_RUN_VM, command.getAuditLogTypeValue());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Test(org.junit.Test)

Example 57 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class RunVmCommandTest method validateIsoPrefixWithTrippleSlash.

@Test
public void validateIsoPrefixWithTrippleSlash() throws Exception {
    String initrd = RunVmCommand.ISO_PREFIX + "/";
    VM vm = createVmForTesting(initrd, null);
    assertEquals(ACTIVE_ISO_PREFIX + "/", vm.getInitrdUrl());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Test(org.junit.Test)

Example 58 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class RunVmCommandTest method validateBootPrefixForInitrdAndKernelImage.

@Test
public void validateBootPrefixForInitrdAndKernelImage() throws Exception {
    String initrd = "/boot";
    String kernelImage = "/boot";
    VM vm = createVmForTesting(initrd, kernelImage);
    assertEquals(initrd, vm.getInitrdUrl());
    assertEquals(kernelImage, vm.getKernelUrl());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Test(org.junit.Test)

Example 59 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class RunVmCommandTest method dontConnectFCLuns.

@Test
public void dontConnectFCLuns() {
    // FC luns are connected physically, they don't have StorageServerConnection set.
    // Make sure if we have an FC lun connection we don't try to connect
    // otherwise NPE will be thrown.
    command.setVm(new VM());
    // create 2 FC lun disks
    LunDisk fcLunDisk = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    fcLunDisk.setLun(lun1);
    LunDisk isciDisk = new LunDisk();
    LUNs lun2 = new LUNs();
    lun2.setLUNId("id2");
    isciDisk.setLun(lun2);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), fcLunDisk);
    command.getVm().getDiskMap().put(Guid.newGuid(), isciDisk);
    List<StorageServerConnections> iscsiLunConnections = new ArrayList<>();
    iscsiLunConnections.add(new StorageServerConnections("path/to/iscsi/connection", "id1", null, null, StorageType.ISCSI, null, null, null));
    when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(Collections.emptyList());
    when(storageServerConnectionDao.getAllForLun("id2")).thenReturn(iscsiLunConnections);
    ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
    doReturn(succesfull()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
    boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
    // for different targets, make sure we connect all but not FC.
    verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
    assertThat(captor.getValue().getConnectionList().size(), is(1));
    assertEquals(captor.getValue().getStorageType(), StorageType.ISCSI);
    assertTrue(connectSucceeded);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 60 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class RunVmCommandTest method validateIsoPrefix.

@Test
public void validateIsoPrefix() throws Exception {
    String initrd = "initrd";
    String kernel = "kernel";
    VM vm = createVmForTesting(RunVmCommand.ISO_PREFIX + initrd, RunVmCommand.ISO_PREFIX + kernel);
    assertEquals(ACTIVE_ISO_PREFIX + "/" + initrd, vm.getInitrdUrl());
    assertEquals(ACTIVE_ISO_PREFIX + "/" + kernel, vm.getKernelUrl());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Test(org.junit.Test)

Aggregations

VM (org.ovirt.engine.core.common.businessentities.VM)591 Test (org.junit.Test)178 Guid (org.ovirt.engine.core.compat.Guid)150 ArrayList (java.util.ArrayList)130 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)82 HashMap (java.util.HashMap)69 List (java.util.List)65 VDS (org.ovirt.engine.core.common.businessentities.VDS)63 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)56 Map (java.util.Map)53 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)53 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)41 QueryType (org.ovirt.engine.core.common.queries.QueryType)36 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)34 Frontend (org.ovirt.engine.ui.frontend.Frontend)34 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)33 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)32 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)32 Collectors (java.util.stream.Collectors)31 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)31