use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class ImportVmFromExternalProviderCommand method adjustDisk.
protected DiskImage adjustDisk(DiskImage image) {
image.setDiskAlias(renameDiskAlias(getVm().getOrigin(), image.getDiskAlias()));
image.setDiskVmElements(image.getDiskVmElements().stream().map(dve -> {
DiskVmElement copy = DiskVmElement.copyOf(dve, image.getId(), getVmId());
updatePassDiscardForDiskVmElement(copy);
return copy;
}).collect(Collectors.toList()));
return image;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class ImportVmCommand method saveDiskVmElement.
protected void saveDiskVmElement(Guid diskId, Guid vmId, DiskVmElement diskVmElement) {
DiskVmElement dve = DiskVmElement.copyOf(diskVmElement, diskId, vmId);
updatePassDiscardForDiskVmElement(dve);
diskVmElementDao.save(dve);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class ImportVmCommand method addVmExternalLuns.
protected void addVmExternalLuns() {
if (getParameters().getVm().getDiskMap() != null) {
List<LunDisk> lunDisks = DisksFilter.filterLunDisks(getParameters().getVm().getDiskMap().values());
for (LunDisk lun : lunDisks) {
StorageType storageType = StorageType.UNKNOWN;
if (lun.getLun().getLunConnections() != null && !lun.getLun().getLunConnections().isEmpty()) {
// We set the storage type based on the first connection since connections should be with the same
// storage type
storageType = lun.getLun().getLunConnections().get(0).getStorageType();
}
lunHelper.proceedDirectLUNInDb(lun.getLun(), storageType);
// Only if the LUN disk does not exists in the setup add it.
if (baseDiskDao.get(lun.getId()) == null) {
baseDiskDao.save(lun);
}
if (diskLunMapDao.get(new DiskLunMapId(lun.getId(), lun.getLun().getLUNId())) == null) {
diskLunMapDao.save(new DiskLunMap(lun.getId(), lun.getLun().getLUNId()));
}
// Add disk VM element to attach the disk to the VM.
DiskVmElement diskVmElement = lun.getDiskVmElementForVm(getVmId());
diskVmElementDao.save(diskVmElement);
getVmDeviceUtils().addDiskDevice(getVmId(), lun.getId(), diskVmElement.isPlugged(), diskVmElement.isReadOnly());
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class OvfUpdateProcessHelper method getVmImagesFromDb.
public ArrayList<DiskImage> getVmImagesFromDb(VM vm) {
ArrayList<DiskImage> allVmImages = new ArrayList<>();
List<DiskImage> filteredDisks = DisksFilter.filterImageDisks(vm.getDiskList(), ONLY_SNAPABLE, ONLY_ACTIVE);
for (DiskImage diskImage : filteredDisks) {
allVmImages.addAll(diskImageDao.getAllSnapshotsForLeaf(diskImage.getImageId()));
}
for (DiskImage disk : allVmImages) {
DiskVmElement dve = diskVmElementDao.get(new VmDeviceId(disk.getId(), vm.getId()));
disk.setDiskVmElements(Collections.singletonList(dve));
}
return allVmImages;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class BlockStorageDiscardFunctionalityHelperTest method createVmDisk.
private DiskVmElement createVmDisk(Guid diskId, boolean passDiscard) {
DiskVmElement diskVmElement = new DiskVmElement(diskId, Guid.newGuid());
diskVmElement.setPassDiscard(passDiscard);
return diskVmElement;
}
Aggregations