use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class AddDiskCommand method executeVmCommand.
@Override
protected void executeVmCommand() {
createNewDiskId();
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getDiskInfo().getId()));
ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm());
switch(getParameters().getDiskInfo().getDiskStorageType()) {
case IMAGE:
createDiskBasedOnImage();
break;
case LUN:
createDiskBasedOnLun();
break;
case CINDER:
createDiskBasedOnCinder();
break;
}
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class CreateSnapshotFromTemplateCommand method removeImage.
private void removeImage() {
RemoveImageParameters removeImageParams = new RemoveImageParameters(getParameters().getDestinationImageId());
removeImageParams.setStorageDomainId(getDestinationStorageDomainId());
removeImageParams.setDbOperationScope(ImageDbOperationScope.NONE);
removeImageParams.setShouldLockImage(false);
removeImageParams.setEntityInfo(new EntityInfo(VdcObjectType.Disk, getDestinationDiskImage().getId()));
ActionReturnValue returnValue = runInternalActionWithTasksContext(ActionType.RemoveImage, removeImageParams);
if (!returnValue.getSucceeded()) {
addAuditLogOnRemoveFailure();
}
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class CopyImageGroupCommand method revertTasks.
@Override
protected void revertTasks() {
if (getParameters().getRevertDbOperationScope() != null) {
Guid destImageId = getParameters().getDestinationImageId();
RemoveImageParameters removeImageParams = new RemoveImageParameters(destImageId);
if (getParameters().getParentCommand() == ActionType.AddVmFromSnapshot) {
removeImageParams.setParentParameters(getParameters());
removeImageParams.setParentCommand(ActionType.CopyImageGroup);
} else {
removeImageParams.setParentParameters(removeImageParams);
removeImageParams.setParentCommand(ActionType.RemoveImage);
removeImageParams.setStorageDomainId(getParameters().getStorageDomainId());
removeImageParams.setDbOperationScope(getParameters().getRevertDbOperationScope());
removeImageParams.setShouldLockImage(getParameters().isShouldLockImageOnRevert());
}
removeImageParams.setEntityInfo(new EntityInfo(VdcObjectType.Disk, getDestinationImageId()));
// Setting the image as the monitored entity, so there will not be dependency
ActionReturnValue returnValue = checkAndPerformRollbackUsingCommand(ActionType.RemoveImage, removeImageParams, null);
if (returnValue.getSucceeded()) {
// Starting to monitor the tasks - RemoveImage is an internal command
// which adds the taskId on the internal task ID list
startPollingAsyncTasks(returnValue.getInternalVdsmTaskIdList());
}
}
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class DestroyImageCommand method executeCommand.
@Override
protected void executeCommand() {
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupId()));
VDSReturnValue vdsReturnValue = null;
try {
vdsReturnValue = runVdsCommand(VDSCommandType.DestroyImage, createVDSParameters());
} catch (EngineException e) {
log.error("Failed to delete image {}/{}", getParameters().getImageGroupId(), getParameters().getImageList().stream().findFirst().get(), e);
if (!getParameters().isLiveMerge()) {
throw e;
}
}
if (vdsReturnValue != null && vdsReturnValue.getCreationInfo() != null) {
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
Guid result = createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId());
getTaskIdList().add(result);
log.info("Successfully started task to remove orphaned volumes resulting from live merge");
} else {
log.info("Retrying deleting image {}/{}", getParameters().getImageGroupId(), getParameters().getImageList().stream().findFirst().get());
MergeStatusReturnValue returnValue = new MergeStatusReturnValue(VmBlockJobType.COMMIT, new HashSet<>(getParameters().getImageList()));
getReturnValue().setActionReturnValue(returnValue);
// At this point, we know that this command was executed during live merge and it is safe to do
// the casting in the next line.
((RemoveSnapshotSingleDiskParameters) getParameters().getParentParameters()).setNextCommandStep(RemoveSnapshotSingleDiskStep.DESTROY_IMAGE);
}
setSucceeded(true);
setCommandStatus(CommandStatus.SUCCEEDED);
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class ImportRepoImageCommand method setupParameters.
private void setupParameters() {
getParameters().setImageGroupID(Guid.newGuid());
getParameters().setDestinationImageId(Guid.newGuid());
if (getParameters().getImportAsTemplate()) {
getParameters().setVmSnapshotId(Guid.newGuid());
}
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupID()));
}
Aggregations