Search in sources :

Example 46 with DiskImage

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

the class LiveMigrateDiskCommand method moveDiskInDB.

private void moveDiskInDB(final Guid sourceStorageDomainId, final Guid targetStorageDomainId, final Guid targetQuota, final Guid targetDiskProfile) {
    if (isMoveDiskInDbSucceded(targetStorageDomainId)) {
        return;
    }
    TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
        for (DiskImage di : diskImageDao.getAllSnapshotsForImageGroup(getParameters().getImageGroupID())) {
            imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(di.getImageId(), sourceStorageDomainId));
            imageStorageDomainMapDao.save(new ImageStorageDomainMap(di.getImageId(), targetStorageDomainId, targetQuota, targetDiskProfile));
            // an exception, we store locally the old quota and disk profile id.
            if (sourceQuotaId == null) {
                sourceQuotaId = di.getQuotaId();
            }
            if (sourceDiskProfileId == null) {
                sourceDiskProfileId = di.getDiskProfileId();
            }
        }
        return null;
    });
}
Also used : ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) ImageStorageDomainMapId(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 47 with DiskImage

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

the class LiveMigrateDiskCommand method validateDestDomainsSpaceRequirements.

protected boolean validateDestDomainsSpaceRequirements() {
    if (!isStorageDomainWithinThresholds(getDstStorageDomain())) {
        return false;
    }
    DiskImage diskImage = getDiskImageByImageId(getParameters().getImageId());
    List<DiskImage> allImageSnapshots = diskImageDao.getAllSnapshotsForLeaf(diskImage.getImageId());
    diskImage.getSnapshots().addAll(allImageSnapshots);
    StorageDomainValidator storageDomainValidator = createStorageDomainValidator(getDstStorageDomain());
    if (!validate(storageDomainValidator.hasSpaceForClonedDisks(Collections.singleton(diskImage)))) {
        return false;
    }
    return true;
}
Also used : StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 48 with DiskImage

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

the class LiveMigrateDiskCommand method updateImagesInfo.

private void updateImagesInfo() {
    for (DiskImage image : diskImageDao.getAllSnapshotsForImageGroup(getParameters().getImageGroupID())) {
        VDSReturnValue ret = runVdsCommand(VDSCommandType.GetImageInfo, new GetImageInfoVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getTargetStorageDomainId(), getParameters().getImageGroupID(), image.getImageId()));
        DiskImage imageFromIRS = (DiskImage) ret.getReturnValue();
        setQcowCompatForSnapshot(image, imageFromIRS);
        DiskImageDynamic diskImageDynamic = diskImageDynamicDao.get(image.getImageId());
        // Update image's actual size in DB
        if (imageFromIRS != null && diskImageDynamic != null) {
            diskImageDynamic.setActualSize(imageFromIRS.getActualSizeInBytes());
            diskImageDynamicDao.update(diskImageDynamic);
        }
    }
}
Also used : GetImageInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 49 with DiskImage

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

the class AddStoragePoolWithStoragesCommand method registerOvfStoreDisks.

private void registerOvfStoreDisks() {
    for (final Guid storageDomainId : getParameters().getStorages()) {
        if (storageDomainStaticDao.get(storageDomainId).getStorageDomainType().isDataDomain()) {
            resetOvfStoreAndUnregisteredDisks();
            TransactionSupport.executeInNewTransaction(() -> {
                List<DiskImage> ovfStoreDiskImages = getAllOVFDisks(storageDomainId, getStoragePool().getId());
                registerAllOvfDisks(ovfStoreDiskImages, storageDomainId);
                List<OvfEntityData> entitiesFromStorageOvfDisk = getEntitiesFromStorageOvfDisk(storageDomainId, getStoragePool().getId());
                // Update unregistered entities
                for (Object ovf : entitiesFromStorageOvfDisk) {
                    OvfEntityData ovfEntityData = (OvfEntityData) ovf;
                    unregisteredOVFDataDao.removeEntity(ovfEntityData.getEntityId(), storageDomainId);
                    unregisteredOVFDataDao.saveOVFData(ovfEntityData);
                    log.info("Adding OVF data of entity id '{}' and entity name '{}'", ovfEntityData.getEntityId(), ovfEntityData.getEntityName());
                }
                initUnregisteredDisksToDB(storageDomainId);
                return null;
            });
        }
    }
}
Also used : OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 50 with DiskImage

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

the class RunVmCommandTest method initDiskImage.

private Guid initDiskImage(VM vm) {
    DiskImage image = new DiskImage();
    Guid storageDomainId = Guid.newGuid();
    image.setId(Guid.newGuid());
    image.setStorageIds(new ArrayList<>(Collections.singletonList(storageDomainId)));
    vm.getDiskMap().put(image.getId(), image);
    return storageDomainId;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)635 Guid (org.ovirt.engine.core.compat.Guid)212 ArrayList (java.util.ArrayList)167 Test (org.junit.Test)132 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)80 VM (org.ovirt.engine.core.common.businessentities.VM)77 HashMap (java.util.HashMap)64 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)62 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)62 List (java.util.List)56 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)48 Map (java.util.Map)39 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)38 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)35 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)34 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)31 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)31 EngineException (org.ovirt.engine.core.common.errors.EngineException)29 ActionType (org.ovirt.engine.core.common.action.ActionType)22 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)22