Search in sources :

Example 66 with DiskVmElement

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

the class VmValidatorTest method validateVMPluggedDisksWithReservationStatus.

private void validateVMPluggedDisksWithReservationStatus(boolean vmHasDisksPluggedWithReservation) {
    DiskVmElement dve = new DiskVmElement(null, vm.getId());
    dve.setUsingScsiReservation(vmHasDisksPluggedWithReservation);
    when(DbFacade.getInstance().getDiskVmElementDao()).thenReturn(diskVmElementDao);
    when(diskVmElementDao.getAllPluggedToVm(vm.getId())).thenReturn(Collections.singletonList(dve));
    if (vmHasDisksPluggedWithReservation) {
        // If the VM has plugged disks using ISCSI reservation the validation should fail
        assertThat(validator.isVmPluggedDiskNotUsingScsiReservation(), failsWith(EngineMessage.ACTION_TYPE_FAILED_VM_USES_SCSI_RESERVATION));
    } else {
        assertThat(validator.isVmPluggedDiskNotUsingScsiReservation(), isValid());
    }
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 67 with DiskVmElement

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

the class VmValidatorTest method canDisableVirtioScsiFail.

@Test
public void canDisableVirtioScsiFail() {
    Disk disk = new DiskImage();
    DiskVmElement dve = new DiskVmElement(disk.getId(), vm.getId());
    dve.setDiskInterface(DiskInterface.VirtIO_SCSI);
    disk.setDiskVmElements(Collections.singletonList(dve));
    assertThat(validator.canDisableVirtioScsi(Collections.singletonList(disk)), failsWith(EngineMessage.CANNOT_DISABLE_VIRTIO_SCSI_PLUGGED_DISKS));
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 68 with DiskVmElement

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

the class DiskValidatorTest method createDiskVmElementUsingScsiReserevation.

private static DiskVmElement createDiskVmElementUsingScsiReserevation() {
    DiskVmElement dve = new DiskVmElement();
    dve.setUsingScsiReservation(true);
    return dve;
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 69 with DiskVmElement

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

the class DiskVmElementValidatorTest method readOnlyIsSupportedByDiskInterface.

@Test
public void readOnlyIsSupportedByDiskInterface() {
    dve.setReadOnly(true);
    DiskVmElement dve = new DiskVmElement();
    dve.setDiskInterface(DiskInterface.VirtIO);
    assertThat(validator.isReadOnlyPropertyCompatibleWithInterface(), isValid());
    dve.setDiskInterface(DiskInterface.VirtIO_SCSI);
    assertThat(validator.isReadOnlyPropertyCompatibleWithInterface(), isValid());
    dve.setReadOnly(false);
    dve.setDiskInterface(DiskInterface.IDE);
    assertThat(validator.isReadOnlyPropertyCompatibleWithInterface(), isValid());
    dve.setReadOnly(true);
    dve.setDiskInterface(DiskInterface.VirtIO);
    assertThat(validator.isReadOnlyPropertyCompatibleWithInterface(), isValid());
    dve.setReadOnly(false);
    dve.setDiskInterface(DiskInterface.VirtIO_SCSI);
    assertThat(validator.isReadOnlyPropertyCompatibleWithInterface(), isValid());
    dve.setDiskInterface(DiskInterface.IDE);
    assertThat(validator.isReadOnlyPropertyCompatibleWithInterface(), isValid());
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Test(org.junit.Test)

Example 70 with DiskVmElement

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

the class DiskVmElementValidatorTest method setUp.

@Before
public void setUp() {
    injectorRule.bind(OsRepository.class, osRepository);
    initializeInterfaceValidation(DiskInterface.VirtIO);
    disk = new DiskImage();
    dve = new DiskVmElement();
    validator = new DiskVmElementValidator(disk, dve);
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Before(org.junit.Before)

Aggregations

DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)91 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)30 Test (org.junit.Test)26 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)23 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)22 Guid (org.ovirt.engine.core.compat.Guid)17 ArrayList (java.util.ArrayList)16 VM (org.ovirt.engine.core.common.businessentities.VM)12 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)11 HashMap (java.util.HashMap)8 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)8 Map (java.util.Map)7 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)7 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)7 ActionType (org.ovirt.engine.core.common.action.ActionType)6 AttachDetachVmDiskParameters (org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 VmDiskOperationParameterBase (org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)5 Collection (java.util.Collection)4