use of com.sequenceiq.freeipa.service.image.ImageService in project cloudbreak by hortonworks.
the class ImageChangeActions method prepareImage.
@Bean(name = "PREPARE_IMAGE_STATE")
public AbstractImageChangeAction<?> prepareImage() {
return new AbstractImageChangeAction<>(ImageChangeEvent.class) {
@Inject
private ImageConverter imageConverter;
@Inject
private ImageService imageService;
@Override
protected void doExecute(StackContext context, ImageChangeEvent payload, Map<Object, Object> variables) throws Exception {
CloudStack cloudStack = getCloudStackConverter().convert(context.getStack());
Image image = imageConverter.convert(imageService.getByStack(context.getStack()));
PrepareImageRequest<Object> request = new PrepareImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStack, image);
LOGGER.info("Prepare image: {}", image);
sendEvent(context, request);
}
@Override
protected Object getFailurePayload(ImageChangeEvent payload, Optional<StackContext> flowContext, Exception ex) {
LOGGER.error("[PREPARE_IMAGE_STATE] failed", ex);
return new StackFailureEvent(IMAGE_CHANGE_FAILED_EVENT.event(), payload.getResourceId(), ex);
}
};
}
Aggregations