Search in sources :

Example 1 with Image

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

the class RemoveSnapshotSingleDiskCommandBase method handleBackwardMerge.

private void handleBackwardMerge(DiskImage topImage, DiskImage baseImage, DiskImage imageFromVdsm) {
    // For backwards merge, the prior base image now has the data associated with the newer
    // snapshot we want to keep.  Re-associate this older image with the newer snapshot.
    // The base snapshot is deleted if everything went well.  In case it's not deleted, we
    // hijack it to preserve a link to the broken image.  This makes the image discoverable
    // so that we can retry the deletion later, yet doesn't corrupt the VM image chain.
    List<DiskImage> children = diskImageDao.getAllSnapshotsForParent(topImage.getImageId());
    if (!children.isEmpty()) {
        DiskImage childImage = children.get(0);
        childImage.setParentId(baseImage.getImageId());
        imageDao.update(childImage.getImage());
    }
    Image oldTopImage = topImage.getImage();
    topImage.setImage(baseImage.getImage());
    baseImage.setImage(oldTopImage);
    Guid oldTopSnapshotId = topImage.getImage().getSnapshotId();
    topImage.getImage().setSnapshotId(baseImage.getImage().getSnapshotId());
    baseImage.getImage().setSnapshotId(oldTopSnapshotId);
    boolean oldTopIsActive = topImage.getImage().isActive();
    topImage.getImage().setActive(baseImage.getImage().isActive());
    VolumeClassification baseImageVolumeClassification = VolumeClassification.getVolumeClassificationByActiveFlag(baseImage.getImage().isActive());
    topImage.getImage().setVolumeClassification(baseImageVolumeClassification);
    baseImage.getImage().setActive(oldTopIsActive);
    VolumeClassification oldTopVolumeClassification = VolumeClassification.getVolumeClassificationByActiveFlag(oldTopIsActive);
    topImage.getImage().setVolumeClassification(oldTopVolumeClassification);
    topImage.setSize(baseImage.getSize());
    topImage.setActualSizeInBytes(imageFromVdsm.getActualSizeInBytes());
    topImage.setImageStatus(ImageStatus.OK);
    baseDiskDao.update(topImage);
    imageDao.update(topImage.getImage());
    updateDiskImageDynamic(imageFromVdsm, topImage);
    baseDiskDao.update(baseImage);
    imageDao.update(baseImage.getImage());
    updateVmConfigurationForImageChange(topImage.getImage().getSnapshotId(), baseImage.getImageId(), topImage);
    updateVmConfigurationForImageRemoval(baseImage.getImage().getSnapshotId(), topImage.getImageId());
}
Also used : VolumeClassification(org.ovirt.engine.core.common.businessentities.storage.VolumeClassification) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Image(org.ovirt.engine.core.common.businessentities.storage.Image) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with Image

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

the class VdsmImagePoller method pollImage.

protected HostJobStatus pollImage(Guid storagePoolId, Guid storageDomainId, Guid imageGroupId, Guid imageId, int executionGeneration, Guid cmdId, ActionType actionType) {
    Image imageInfo = ((DiskImage) vdsCommandsHelper.runVdsCommandWithoutFailover(VDSCommandType.GetVolumeInfo, new GetVolumeInfoVDSCommandParameters(storagePoolId, storageDomainId, imageGroupId, imageId), storagePoolId, null).getReturnValue()).getImage();
    if (imageInfo.getLeaseStatus() != null && !imageInfo.getLeaseStatus().isFree()) {
        log.info("Command {} id: '{}': the volume lease is not FREE - the job is running", actionType, cmdId);
        return HostJobStatus.running;
    }
    if (imageInfo.getGeneration() == executionGeneration + 1) {
        log.info("Command {} id: '{}': the volume lease is free and the generation was incremented - the " + "job execution has completed successfully", actionType, cmdId);
        return HostJobStatus.done;
    }
    if (imageInfo.getGeneration() == executionGeneration + StorageConstants.ENTITY_FENCING_GENERATION_DIFF) {
        log.info("Command {} id: '{}': the volume generation was incremented by the job fencing diff - the job " + "was fenced and its status can be considered as failed", actionType, cmdId);
        return HostJobStatus.failed;
    }
    log.info("Command {} id: '{}': couldn't determine the status of the job by entity polling", actionType, cmdId);
    return null;
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Image(org.ovirt.engine.core.common.businessentities.storage.Image) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) GetVolumeInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetVolumeInfoVDSCommandParameters)

Example 3 with Image

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

the class ImageDaoTest method testUpdateStatus.

@Test
public void testUpdateStatus() {
    dao.updateStatus(EXISTING_IMAGE_ID, ImageStatus.LOCKED);
    Image imageFromDb = dao.get(EXISTING_IMAGE_ID);
    assertNotNull(imageFromDb);
    assertEquals(ImageStatus.LOCKED, imageFromDb.getStatus());
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Image(org.ovirt.engine.core.common.businessentities.storage.Image) Test(org.junit.Test)

Example 4 with Image

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

the class ImageDaoTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    newImage = new Image();
    newImage.setActive(true);
    newImage.setVolumeClassification(VolumeClassification.Volume);
    newImage.setTemplateImageId(EXISTING_IMAGE_DISK_TEMPLATE_ID);
    newImage.setSnapshotId(EXISTING_SNAPSHOT_ID);
    newImage.setId(Guid.newGuid());
    newImage.setVolumeFormat(VolumeFormat.COW);
    newImage.setQcowCompat(QcowCompat.QCOW2_V3);
    newImage.setVolumeType(VolumeType.Sparse);
    newImage.setDiskId(Guid.newGuid());
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Image(org.ovirt.engine.core.common.businessentities.storage.Image)

Example 5 with Image

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

the class ImportRepoImageCommand method setQcowCompatForQcowImage.

private void setQcowCompatForQcowImage() {
    Image image = imageDao.get(getDiskImage().getImageId());
    if (getDiskImage().getDiskStorageType() == DiskStorageType.IMAGE && getDiskImage().getVolumeFormat() == VolumeFormat.COW) {
        image.setQcowCompat(getDiskImage().getQcowCompat());
        imageDao.update(image);
    }
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Image(org.ovirt.engine.core.common.businessentities.storage.Image)

Aggregations

DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)11 Image (org.ovirt.engine.core.common.businessentities.storage.Image)11 Test (org.junit.Test)3 Guid (org.ovirt.engine.core.compat.Guid)3 DiskInterface (org.ovirt.engine.core.common.businessentities.storage.DiskInterface)1 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)1 RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)1 VolumeClassification (org.ovirt.engine.core.common.businessentities.storage.VolumeClassification)1 VolumeFormat (org.ovirt.engine.core.common.businessentities.storage.VolumeFormat)1 VolumeType (org.ovirt.engine.core.common.businessentities.storage.VolumeType)1 GetVolumeInfoVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetVolumeInfoVDSCommandParameters)1 RandomUtils (org.ovirt.engine.core.utils.RandomUtils)1