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);
}
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;
}
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));
}
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());
}
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());
}
Aggregations