Search in sources :

Example 51 with DiskVmElement

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

the class AddDiskCommandTest method testAddingIDELunExceedsSlotLimit.

@Test
public void testAddingIDELunExceedsSlotLimit() {
    mockInterfaceList();
    LunDisk disk = createISCSILunDisk();
    command.getParameters().setDiskInfo(disk);
    command.getParameters().getDiskVmElement().setDiskInterface(DiskInterface.IDE);
    VM vm = mockVm();
    mockMaxPciSlots();
    // use maximum slots for IDE - validate expected to succeed.
    mockOtherVmDisks(vm, VmCommand.MAX_IDE_SLOTS - 1, DiskInterface.IDE);
    ValidateTestUtils.runAndAssertValidateSuccess(command);
    LunDisk newDisk = createISCSILunDisk();
    DiskVmElement dve = new DiskVmElement(disk.getId(), vmId);
    dve.setDiskInterface(DiskInterface.IDE);
    newDisk.setDiskVmElements(Collections.singletonList(dve));
    vm.getDiskMap().put(newDisk.getId(), newDisk);
    ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_EXCEEDED_MAX_IDE_SLOTS);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 52 with DiskVmElement

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

the class PostDeleteActionHandlerTest method createDiskVmElementWithPassDiscardValue.

private DiskVmElement createDiskVmElementWithPassDiscardValue(boolean passDiscard) {
    DiskVmElement diskVmElement = new DiskVmElement();
    diskVmElement.setPassDiscard(passDiscard);
    return diskVmElement;
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 53 with DiskVmElement

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

the class RemoveImageCommandTest method testRemoveImageFromSnapshotConfiguration.

@Test
public void testRemoveImageFromSnapshotConfiguration() throws OvfReaderException {
    Guid vmId = Guid.newGuid();
    VM vm = new VM();
    vm.setId(vmId);
    vm.setStoragePoolId(Guid.newGuid());
    vm.setVmtName(RandomUtils.instance().nextString(10));
    vm.setOrigin(OriginType.OVIRT);
    vm.setDbGeneration(1L);
    Guid vmSnapshotId = Guid.newGuid();
    DiskImage disk1 = addTestDisk(vm, vmSnapshotId);
    DiskVmElement dve1 = new DiskVmElement(disk1.getId(), vm.getId());
    dve1.setDiskInterface(DiskInterface.VirtIO);
    disk1.setDiskVmElements(Collections.singletonList(dve1));
    DiskImage disk2 = addTestDisk(vm, vmSnapshotId);
    DiskVmElement dve2 = new DiskVmElement(disk2.getId(), vm.getId());
    dve2.setDiskInterface(DiskInterface.IDE);
    disk2.setDiskVmElements(Collections.singletonList(dve2));
    mcr.mockConfigValue(ConfigValues.PassDiscardSupported, Version.getLast(), true);
    mcr.mockConfigValue(ConfigValues.PassDiscardSupported, Version.ALL.get(0), true);
    mcr.mockConfigValue(ConfigValues.MaxNumOfVmSockets, Version.getLast(), 16);
    mcr.mockConfigValue(ConfigValues.MaxNumOfVmSockets, Version.ALL.get(0), 16);
    mcr.mockConfigValue(ConfigValues.MaxNumOfVmCpus, Version.getLast(), 16);
    mcr.mockConfigValue(ConfigValues.MaxNumOfVmCpus, Version.ALL.get(0), 16);
    ArrayList<DiskImage> disks = new ArrayList<>(Arrays.asList(disk1, disk2));
    FullEntityOvfData fullEntityOvfDataForExport = new FullEntityOvfData(vm);
    fullEntityOvfDataForExport.setDiskImages(disks);
    String ovf = ovfManager.exportVm(vm, fullEntityOvfDataForExport, Version.getLast());
    Snapshot snap = new Snapshot();
    snap.setVmConfiguration(ovf);
    snap.setId(vmSnapshotId);
    doReturn(disk2).when(cmd).getDiskImage();
    doReturn(disk2).when(cmd).getImage();
    doReturn(disk2.getId()).when(cmd).getImageId();
    Snapshot actual = imagesHandler.prepareSnapshotConfigWithAlternateImage(snap, disk2.getImageId(), null, ovfManager);
    String actualOvf = actual.getVmConfiguration();
    VM emptyVm = new VM();
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(emptyVm);
    ovfManager.importVm(actualOvf, emptyVm, fullEntityOvfData);
    assertEquals("Wrong number of disks", 1, fullEntityOvfData.getDiskImages().size());
    assertEquals("Wrong disk", disk1, fullEntityOvfData.getDiskImages().get(0));
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 54 with DiskVmElement

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

the class DiskVmElementDaoTest method testVmElementDiskUnpluggedStatus.

@Test
public void testVmElementDiskUnpluggedStatus() {
    DiskVmElement dveUnplugged = dao.get(new VmDeviceId(UNPLUGGED_DISK_ID, FixturesTool.VM_RHEL5_POOL_57));
    assertFalse(dveUnplugged.isPlugged());
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) Test(org.junit.Test)

Example 55 with DiskVmElement

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

the class DiskVmElementDaoTest method testGetFilteredWithPermissions.

@Test
public void testGetFilteredWithPermissions() {
    DiskVmElement result = dao.get(getExistingEntityId(), PRIVILEGED_USER_ID, true);
    assertNotNull(result);
    assertEquals(getExistingEntityId().toString(), result.getId().toString());
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Test(org.junit.Test)

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