Search in sources :

Example 61 with VM

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

the class RunVmCommandTest method validateInitrdWithSlashOnly.

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

Example 62 with VM

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

the class RunVmCommandTest method testValidate.

@Test
public void testValidate() {
    final VM vm = new VM();
    vm.setStatus(VMStatus.Down);
    command.setVm(vm);
    command.setStoragePool(new StoragePool());
    doReturn(true).when(command).checkRngDeviceClusterCompatibility();
    doReturn(true).when(command).checkPayload(any());
    doReturn(ValidationResult.VALID).when(command).checkDisksInBackupStorage();
    command.setCluster(new Cluster());
    ValidateTestUtils.runAndAssertValidateSuccess(command);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Test(org.junit.Test)

Example 63 with VM

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

the class RunVmCommandTest method testFlowOnStatelessWithDisks.

@Test
public void testFlowOnStatelessWithDisks() {
    final VM vm = new VM();
    vm.setStatus(VMStatus.Down);
    vm.getDiskList().add(new DiskImage());
    command.setVm(vm);
    command.getParameters().setRunAsStateless(true);
    doReturn(false).when(command).isStatelessSnapshotExistsForVm();
    doNothing().when(command).fetchVmDisksFromDb();
    assertEquals(RunVmFlow.CREATE_STATELESS_IMAGES, command.getFlow());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 64 with VM

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

the class RunVmCommandTest method oneConnectFailed.

@Test
public void oneConnectFailed() {
    command.setVm(new VM());
    // create 2 lun disks
    LunDisk lunDisk1 = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    lunDisk1.setLun(lun1);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk1);
    List<StorageServerConnections> connections = new ArrayList<>();
    // luns have the same backing targets
    connections.add(new StorageServerConnections("/path/to/con1", "id1", null, null, StorageType.ISCSI, null, null, null));
    when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(connections);
    ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
    doReturn(new VDSReturnValue()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
    boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
    // for same targets, connect only once
    verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
    assertThat(captor.getValue().getConnectionList().size(), is(1));
    assertFalse(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) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Test(org.junit.Test)

Example 65 with VM

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

the class AddVmTemplateCommandTest method createVM.

private VM createVM() {
    Guid vmId = Guid.newGuid();
    Guid clusterId = Guid.newGuid();
    Guid spId = Guid.newGuid();
    VM vm = new VM();
    vm.setId(vmId);
    vm.setClusterId(clusterId);
    vm.setStoragePoolId(spId);
    vm.setVmOs(14);
    return vm;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid)

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