use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class RemoveSnapshotSingleDiskCommandBase method updateVmConfigurationForImageRemoval.
private void updateVmConfigurationForImageRemoval(final Guid snapshotId, final Guid imageId) {
try {
lockVmSnapshotsWithWait(getVm());
TransactionSupport.executeInNewTransaction(() -> {
Snapshot s = snapshotDao.get(snapshotId);
s = imagesHandler.prepareSnapshotConfigWithoutImageSingleImage(s, imageId, ovfManager);
snapshotDao.update(s);
return null;
});
} finally {
if (getSnapshotsEngineLock() != null) {
lockManager.releaseLock(getSnapshotsEngineLock());
}
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class RemoveSnapshotSingleDiskCommandBase method updateVmConfigurationForImageChange.
private void updateVmConfigurationForImageChange(final Guid snapshotId, final Guid oldImageId, final DiskImage newImage) {
try {
lockVmSnapshotsWithWait(getVm());
TransactionSupport.executeInNewTransaction(() -> {
Snapshot s = snapshotDao.get(snapshotId);
s = imagesHandler.prepareSnapshotConfigWithAlternateImage(s, oldImageId, newImage, ovfManager);
snapshotDao.update(s);
return null;
});
} finally {
if (getSnapshotsEngineLock() != null) {
lockManager.releaseLock(getSnapshotsEngineLock());
}
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class RestoreAllSnapshotsCommand method initializeSnapshotsLeasesDomainIds.
private void initializeSnapshotsLeasesDomainIds() {
previewedSnapshotLeaseDomainId = getVm().getLeaseStorageDomainId();
Snapshot activeBeforeSnapshot = snapshotDao.get(getVmId(), SnapshotType.PREVIEW);
// activeBeforeSnapshot can be null in case of restore of stateless VM
if (activeBeforeSnapshot != null && activeBeforeSnapshot.getVmConfiguration() != null) {
activeBeforeSnapshotLeaseDomainId = OvfUtils.fetchLeaseDomainId(activeBeforeSnapshot.getVmConfiguration());
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class RestoreAllSnapshotsCommand method findSnapshotsWithOnlyIllegalDisks.
private Set<Guid> findSnapshotsWithOnlyIllegalDisks() {
List<Snapshot> newerSnapshots = getNewerSnapshots(snapshot);
Set<Guid> snapshotsToRemove = new HashSet<>();
newerSnapshots.forEach(snapshot -> {
VM vm = snapshotVmConfigurationHelper.getVmFromConfiguration(snapshot.getVmConfiguration(), snapshot.getVmId(), snapshot.getId());
if (vm != null) {
boolean shouldRemove = vm.getImages().isEmpty() || vm.getImages().stream().allMatch(diskImage -> diskImage.getImageStatus() == ImageStatus.ILLEGAL);
if (shouldRemove) {
snapshotsToRemove.add(snapshot.getId());
}
}
});
return snapshotsToRemove;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ColdMergeSnapshotSingleDiskCommand method endSuccessfully.
@Override
public void endSuccessfully() {
syncDbRecords(VmBlockJobType.COMMIT, getImageInfoFromVdsm(getDiskImage()), Collections.singleton(getDestinationImageId()), true);
if (getParameters().getVmSnapshotId() != null) {
lockVmSnapshotsWithWait(getVm());
Snapshot snapshot = snapshotDao.get(getParameters().getVmSnapshotId());
Snapshot snapshotWithoutImage = imagesHandler.prepareSnapshotConfigWithoutImageSingleImage(snapshot, getParameters().getImageId(), ovfManager);
snapshotDao.update(snapshotWithoutImage);
if (getSnapshotsEngineLock() != null) {
lockManager.releaseLock(getSnapshotsEngineLock());
}
}
setSucceeded(true);
}
Aggregations