use of org.ovirt.engine.core.common.action.RemoveSnapshotSingleDiskParameters in project ovirt-engine by oVirt.
the class MergeStatusCommand method attemptResolution.
public void attemptResolution() {
Set<Guid> images;
if (vmDynamicDao.get(getParameters().getVmId()).getStatus().isNotRunning()) {
StoragePool pool = storagePoolDao.get(getParameters().getStoragePoolId());
if (pool.getSpmVdsId() == null || pool.getStatus() != StoragePoolStatus.Up) {
log.info("VM down, waiting on SPM election to resolve Live Merge");
setSucceeded(true);
return;
} else {
log.error("VM is not running, proceeding with Live Merge recovery");
images = getVolumeChainFromRecovery();
}
} else {
images = getVolumeChain();
}
if (images == null || images.isEmpty()) {
log.error("Failed to retrieve images list of VM {}. Retrying ...", getParameters().getVmId());
setCommandStatus(CommandStatus.SUCCEEDED);
setSucceeded(true);
// As this command is executed only during live merge flow, the following casting is safe.
((RemoveSnapshotSingleDiskParameters) getParameters().getParentParameters()).setNextCommandStep(RemoveSnapshotSingleDiskStep.MERGE_STATUS);
return;
}
Set<Guid> imagesToRemove = getImagesToRemove();
images.retainAll(imagesToRemove);
if (images.size() != 1) {
log.error("Failed to live merge, still in volume chain: {}", images);
setCommandStatus(CommandStatus.FAILED);
return;
}
if (!images.contains(getParameters().getBaseImage().getImageId())) {
// If the base image isn't found in qemu chain, it means that the image was already deleted.
// In this case, we will not allow PULL merge but rather ask the user to check if the parent
// snapshot contains illegal volume(s). If so, that snapshot must be deleted before deleting
// other snapshots
addCustomValue("SnapshotName", snapshotDao.get(getParameters().getBaseImage().getSnapshotId()).getDescription());
addCustomValue("BaseVolumeId", getParameters().getBaseImage().getImageId().toString());
auditLog(this, AuditLogType.USER_REMOVE_SNAPSHOT_FINISHED_FAILURE_BASE_IMAGE_NOT_FOUND);
setCommandStatus(CommandStatus.FAILED);
return;
}
imagesToRemove.removeAll(images);
log.info("Successfully removed volume(s): {}", imagesToRemove);
// For now, only COMMIT type is supported
log.info("Volume merge type '{}'", VmBlockJobType.COMMIT.name());
MergeStatusReturnValue returnValue = new MergeStatusReturnValue(VmBlockJobType.COMMIT, imagesToRemove);
getReturnValue().setActionReturnValue(returnValue);
setSucceeded(true);
persistCommand(getParameters().getParentCommand(), true);
setCommandStatus(CommandStatus.SUCCEEDED);
}
Aggregations