use of com.cloud.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event in project cosmic by MissionCriticalCloud.
the class VolumeServiceImpl method createVolumeFromSnapshotCallback.
protected Void createVolumeFromSnapshotCallback(final AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, final CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
final CopyCommandResult result = callback.getResult();
final VolumeInfo volume = (VolumeInfo) context.templateOnStore;
final SnapshotInfo snapshot = context.snapshot;
final VolumeApiResult apiResult = new VolumeApiResult(volume);
Event event = null;
if (result.isFailed()) {
apiResult.setResult(result.getResult());
event = Event.OperationFailed;
} else {
event = Event.OperationSuccessed;
}
try {
if (result.isSuccess()) {
volume.processEvent(event, result.getAnswer());
} else {
volume.processEvent(event);
}
snapshot.processEvent(event);
} catch (final Exception e) {
s_logger.debug("create volume from snapshot failed", e);
apiResult.setResult(e.toString());
}
final AsyncCallFuture<VolumeApiResult> future = context.future;
future.complete(apiResult);
return null;
}
Aggregations