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());
}
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;
}
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());
}
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());
}
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);
}
}
Aggregations