use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class MultipleDiskVmElementValidatorTest method setUp.
@Before
public void setUp() {
diskWithOneVmElement = createDiskImage();
diskWithOneVmElement.setDiskAlias("diskWithOneVmElement");
diskVmElement1 = new DiskVmElement(diskWithOneVmElement.getId(), Guid.newGuid());
diskWithTwoVmElements = createDiskImage();
diskWithOneVmElement.setDiskAlias("diskWithTwoVmElements");
diskVmElement2 = new DiskVmElement(diskWithOneVmElement.getId(), Guid.newGuid());
diskVmElement3 = new DiskVmElement(diskWithTwoVmElements.getId(), Guid.newGuid());
diskToDiskVmElements = new HashMap<>();
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class ImportRepoImageCommand method attachDiskToTemplate.
private void attachDiskToTemplate(Guid templateId) {
DiskImage templateDiskImage = getParameters().getDiskImage();
DiskVmElement dve = new DiskVmElement(templateDiskImage.getId(), templateId);
dve.setBoot(true);
dve.setDiskInterface(DiskInterface.VirtIO);
diskVmElementDao.save(dve);
vmDeviceUtils.addDiskDevice(templateId, templateDiskImage.getId());
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class BlockStorageDiscardFunctionalityHelper method logIfDisksWithIllegalPassDiscardExist.
public void logIfDisksWithIllegalPassDiscardExist(Guid vmId) {
Collection<DiskImage> disks = DisksFilter.filterImageDisks(diskDao.getAllForVm(vmId));
Collection<DiskVmElement> diskVmElements = diskVmElementDao.getAllForVm(vmId);
Map<Disk, DiskVmElement> diskToDiskVmElement = diskHandler.getDiskToDiskVmElementMap(disks, diskVmElements);
Map<Guid, Guid> diskIdToDestSdId = disks.stream().collect(Collectors.toMap(DiskImage::getId, diskImage -> diskImage.getStorageIds().get(0)));
MultipleDiskVmElementValidator multipleDiskVmElementValidator = new MultipleDiskVmElementValidator(diskToDiskVmElement);
Collection<Guid> disksWithoutSupportForPassDiscard = multipleDiskVmElementValidator.getDisksWithoutSupportForPassDiscard(diskIdToDestSdId);
if (!disksWithoutSupportForPassDiscard.isEmpty()) {
AuditLogable auditLog = new AuditLogableImpl();
auditLog.addCustomValue("DisksIds", disksWithoutSupportForPassDiscard.stream().map(Guid::toString).collect(Collectors.joining(", ")));
auditLogDirector.log(auditLog, AuditLogType.DISKS_WITH_ILLEGAL_PASS_DISCARD_EXIST);
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class VmDeviceCommonUtilsTest method testUpdateVmDevicesBootOrder.
@Test
public void testUpdateVmDevicesBootOrder() {
Map<VmDeviceId, DiskVmElement> idToDiskElement = new HashMap<>();
List<VmNetworkInterface> interfaces = new LinkedList<>();
VmDevice nic1 = createNetworkInterface(true, NIC_1_NAME, interfaces);
VmDevice unmanagedNic = createUnmanagedNetworkInterface(true);
VmDevice nic2 = createNetworkInterface(true, NIC_2_NAME, interfaces);
VmDevice nonBootableNic = createNetworkInterface(false, "", interfaces);
VmDevice bootableDisk = createDiskDevice(true, idToDiskElement);
VmDevice nonBootableDisk = createDiskDevice(false, idToDiskElement);
VmDevice cd = createCdRomDevice();
doReturn(BootSequence.DNC).when(vm).getDefaultBootSequence();
// it is important that nic2 will be before nic1 to ensure their boot order is
// ordered according to their names and not according to their position in the list
VmDeviceCommonUtils.updateVmDevicesBootOrder(vm.getDefaultBootSequence(), Arrays.asList(bootableDisk, nic2, cd, nic1, nonBootableDisk, unmanagedNic), interfaces, idToDiskElement);
int index = 1;
assertEquals("Wrong boot order for CD", index++, cd.getBootOrder());
assertEquals("Wrong boot order for nic1", index++, nic1.getBootOrder());
assertEquals("Wrong boot order for nic2", index++, nic2.getBootOrder());
assertEquals("Wrong boot order for non bootable nic", 0, nonBootableNic.getBootOrder());
assertEquals("Wrong boot order for unmanaged nic", 0, unmanagedNic.getBootOrder());
assertEquals("Wrong boot order for bootable disk", index++, bootableDisk.getBootOrder());
assertEquals("Wrong boot order for non bootable disk", 0, nonBootableDisk.getBootOrder());
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class VmDeviceCommonUtilsTest method createDiskDevice.
private VmDevice createDiskDevice(boolean boot, Map<VmDeviceId, DiskVmElement> idToDiskElement) {
Guid id = Guid.newGuid();
VmDevice device = new VmDevice();
device.setType(VmDeviceGeneralType.DISK);
device.setDevice(VmDeviceType.DISK.getName());
device.setId(new VmDeviceId(id, null));
DiskVmElement dve = new DiskVmElement(new VmDeviceId(id, null));
dve.setBoot(boot);
idToDiskElement.put(dve.getId(), dve);
return device;
}
Aggregations