Skip to content

Commit

Permalink
abc
Browse files Browse the repository at this point in the history
  • Loading branch information
ekononov committed Jun 24, 2024
1 parent 1043c13 commit 34af2a5
Showing 1 changed file with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import org.ovirt.engine.core.dao.DiskImageDynamicDao;
import org.ovirt.engine.core.dao.ImageDao;
import org.ovirt.engine.core.dao.ImageStorageDomainMapDao;
import org.ovirt.engine.core.dao.SnapshotDao;
import org.ovirt.engine.core.dao.StorageDomainDao;
import org.ovirt.engine.core.dao.StorageDomainStaticDao;
import org.ovirt.engine.core.dao.VmDao;
Expand Down Expand Up @@ -128,6 +129,8 @@ public class LiveMigrateDiskCommand<T extends LiveMigrateDiskParameters> extends
@Inject
@Typed(SerialChildCommandsExecutionCallback.class)
private Instance<SerialChildCommandsExecutionCallback> callbackProvider;
@Inject
private SnapshotDao snapshotDao;

private Map<Guid, DiskImage> diskImagesMap = new HashMap<>();

Expand Down Expand Up @@ -252,7 +255,8 @@ public boolean performNextOperation(int completedChildCount) {
if (getParameters().getLiveDiskMigrateStage() == LiveDiskMigrateStage.CREATE_SNAPSHOT) {
runInternalAction(ActionType.CloneImageGroupVolumesStructure,
buildCloneImageGroupVolumesStructureCommandParams(),
ExecutionHandler.createInternalJobContext(createStepsContext(StepEnum.CLONE_IMAGE_STRUCTURE)));
ExecutionHandler.createInternalJobContext(createStepsContext(StepEnum.CLONE_IMAGE_STRUCTURE,
Collections.emptyMap())));
updateStage(LiveDiskMigrateStage.CLONE_IMAGE_STRUCTURE);
return true;
}
Expand Down Expand Up @@ -301,7 +305,8 @@ public boolean performNextOperation(int completedChildCount) {

updateStage(LiveDiskMigrateStage.AUTO_GENERATED_SNAPSHOT_REMOVE_START);
CommandContext commandContext =
ExecutionHandler.createInternalJobContext(createStepsContext(StepEnum.MERGE_SNAPSHOTS));
ExecutionHandler.createInternalJobContext(createStepsContext(StepEnum.MERGE_SNAPSHOTS,
getMergeSnapshotsJobMessageProperties()));
removeAutogeneratedSnapshot(commandContext, getActionType(), getParameters());
updateStage(LiveDiskMigrateStage.AUTO_GENERATED_SNAPSHOT_REMOVE_END);

Expand Down Expand Up @@ -348,11 +353,11 @@ private void removeAutogeneratedSnapshot(CommandContext commandContext, ActionTy
commandContext);
}

private CommandContext createStepsContext(StepEnum step) {
private CommandContext createStepsContext(StepEnum step, Map<String, String> jobMessageProperties) {
Step addedStep = executionHandler.addSubStep(getExecutionContext(),
getExecutionContext().getJob().getStep(StepEnum.EXECUTING),
step,
ExecutionMessageDirector.resolveStepMessage(step, Collections.emptyMap()));
ExecutionMessageDirector.resolveStepMessage(step, jobMessageProperties));
ExecutionContext ctx = new ExecutionContext();
ctx.setStep(addedStep);
ctx.setMonitored(true);
Expand Down Expand Up @@ -551,7 +556,8 @@ private void syncImageData() {
parameters.setLive(true);
}

runInternalAction(ActionType.CopyImageGroupVolumesData, parameters, createStepsContext(StepEnum.SYNC_IMAGE_DATA));
runInternalAction(ActionType.CopyImageGroupVolumesData, parameters, createStepsContext(StepEnum.SYNC_IMAGE_DATA,
Collections.emptyMap()));
}

private void replicateDiskStart() {
Expand Down Expand Up @@ -824,4 +830,20 @@ public Map<String, String> getJobMessageProperties() {
}
return jobProperties;
}

private Map<String, String> getMergeSnapshotsJobMessageProperties() {
DiskImage diskImage = diskImageDao.getSnapshotById(getParameters().getImageId());
DiskImage destDiskImage = diskImageDao.getSnapshotById(getParameters().getDestinationImageId());

Map<String, String> jobMessageProperties = new HashMap<>();
jobMessageProperties.put(VdcObjectType.Disk.name().toLowerCase(), diskImage.getDiskAlias());
jobMessageProperties.put("sourcesnapshot",
Optional.ofNullable(snapshotDao.get(diskImage.getVmSnapshotId()).getDescription()).orElse(""));
jobMessageProperties.put("destinationsnapshot",
Optional.ofNullable(snapshotDao.get(destDiskImage.getVmSnapshotId()).getDescription()).orElse(""));

return jobMessageProperties;

}

}

0 comments on commit 34af2a5

Please sign in to comment.