use of org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters in project ovirt-engine by oVirt.
the class TryBackToAllSnapshotsOfVmCommand method buildCinderChildCommandParameters.
private CreateCinderSnapshotParameters buildCinderChildCommandParameters(CinderDisk cinderDisk, Guid newSnapshotId) {
CreateCinderSnapshotParameters createParams = new CreateCinderSnapshotParameters(cinderDisk.getImageId());
createParams.setContainerId(cinderDisk.getId());
createParams.setStorageDomainId(cinderDisk.getStorageIds().get(0));
createParams.setDestinationImageId(cinderDisk.getImageId());
createParams.setVmSnapshotId(newSnapshotId);
createParams.setParentCommand(getActionType());
createParams.setParentParameters(getParameters());
return createParams;
}
use of org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters in project ovirt-engine by oVirt.
the class CreateCinderSnapshotCommandCallback method childCommandsExecutionEnded.
@Override
protected void childCommandsExecutionEnded(CommandBase<?> command, boolean anyFailed, List<Guid> childCmdIds, CommandExecutionStatus status, int completedChildren) {
CreateCinderSnapshotCommand<CreateCinderSnapshotParameters> createCinderSnapshotCommand = (CreateCinderSnapshotCommand<CreateCinderSnapshotParameters>) command;
CreateCinderSnapshotParameters parameters = createCinderSnapshotCommand.getParameters();
Guid diskId = parameters.getDestinationImageId();
ImageStatus imageStatus;
if (parameters.getSnapshotType().equals(Snapshot.SnapshotType.STATELESS)) {
imageStatus = createCinderSnapshotCommand.getCinderBroker().getDiskStatus(diskId);
} else {
imageStatus = createCinderSnapshotCommand.getCinderBroker().getSnapshotStatus(diskId);
}
DiskImage disk = diskImageDao.getSnapshotById(diskId);
if (imageStatus != null && imageStatus != disk.getImageStatus()) {
switch(imageStatus) {
case OK:
setCommandEndStatus(command, false, status, childCmdIds);
break;
case ILLEGAL:
setCommandEndStatus(command, true, status, childCmdIds);
break;
}
}
}
use of org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters in project ovirt-engine by oVirt.
the class CreateSnapshotDiskCommand method buildChildCommandParameters.
private CreateCinderSnapshotParameters buildChildCommandParameters(DiskImage cinderDisk) {
CreateCinderSnapshotParameters createParams = new CreateCinderSnapshotParameters(((CinderDisk) diskDao.get(cinderDisk.getId())).getImageId());
createParams.setVmSnapshotId(getParameters().getNewActiveSnapshotId());
createParams.setStorageDomainId(cinderDisk.getStorageIds().get(0));
createParams.setDescription(getParameters().getDescription());
createParams.setSnapshotType(getParameters().getSnapshotType());
createParams.setParentCommand(getActionType());
createParams.setParentParameters(getParameters());
return createParams;
}
use of org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters in project ovirt-engine by oVirt.
the class CreateSnapshotDiskCommand method executeCommand.
@Override
protected void executeCommand() {
for (DiskImage disk : getDisksList()) {
if (disk.getDiskStorageType() == DiskStorageType.CINDER) {
CreateCinderSnapshotParameters params = buildChildCommandParameters(disk);
params.setQuotaId(disk.getQuotaId());
Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.CreateCinderSnapshot, params, cloneContext().withoutCompensationContext().withoutLock());
try {
ActionReturnValue actionReturnValue = future.get();
if (!actionReturnValue.getSucceeded()) {
log.error("Error creating snapshot for Cinder disk '{}'", disk.getDiskAlias());
throw new EngineException(EngineError.CINDER_ERROR, "Failed to create snapshot!");
}
} catch (InterruptedException | ExecutionException e) {
log.error("Error creating snapshot for Cinder disk '{}': {}", disk.getDiskAlias(), e.getMessage());
throw new EngineException(EngineError.CINDER_ERROR, "Failed to create snapshot!");
}
continue;
}
ActionReturnValue actionReturnValue = runInternalAction(ActionType.CreateSnapshot, buildCreateSnapshotParameters(disk), ExecutionHandler.createDefaultContextForTasks(getContext()));
if (actionReturnValue.getSucceeded()) {
getTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
} else {
throw new EngineException(actionReturnValue.getFault().getError(), "Failed to create snapshot!");
}
}
setSucceeded(true);
}
Aggregations