Search in sources :

Example 1 with DiskVmElement

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;
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 2 with DiskVmElement

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);
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 3 with DiskVmElement

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());
        }
    }
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) DiskLunMapId(org.ovirt.engine.core.common.businessentities.storage.DiskLunMapId) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) DiskLunMap(org.ovirt.engine.core.common.businessentities.storage.DiskLunMap)

Example 4 with DiskVmElement

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;
}
Also used : ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 5 with DiskVmElement

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;
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

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