class StackImageUpdateActions {

    @Bean(name = "IMAGE_PREPARE_STATE")
    public AbstractStackImageUpdateAction<?> prepareImageAction() {
        return new AbstractStackImageUpdateAction<>(StackEvent.class) {
            @Override
            protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
                getStackCreationService().prepareImage(context.getStack());
                try {
                    CloudStack cloudStack = getCloudStackConverter().convert(context.getStack());
                    Image image = getImageService().getImage(context.getCloudContext().getId());
                    PrepareImageRequest<Selectable> request =
                            new PrepareImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStack, image);
                    sendEvent(context, request);
                } catch (CloudbreakImageNotFoundException e) {
                    throw new CloudbreakServiceException(e);
                }
            }
        };
    }

}