use of com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest in project cloudbreak by hortonworks.
the class ServiceProviderSetupAdapter method checkImage.
public ImageStatusResult checkImage(Stack stack) throws Exception {
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
Image image = imageService.getImage(stack.getId());
CheckImageRequest<CheckImageResult> checkImageRequest = new CheckImageRequest<>(cloudContext, cloudCredential, cloudStackConverter.convert(stack), image);
LOGGER.info("Triggering event: {}", checkImageRequest);
eventBus.notify(checkImageRequest.selector(), eventFactory.createEvent(checkImageRequest));
try {
CheckImageResult res = checkImageRequest.await();
LOGGER.info("Result: {}", res);
if (res.getErrorDetails() != null) {
LOGGER.error("Failed to check image state", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
return new ImageStatusResult(res.getImageStatus(), res.getStatusProgressValue());
} catch (InterruptedException e) {
LOGGER.error("Error while executing check image", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest in project cloudbreak by hortonworks.
the class StackCreationService method checkImage.
public CheckImageResult checkImage(StackContext context) {
try {
Stack stack = context.getStack();
Image image = imageService.getImage(stack.getId());
CheckImageRequest<CheckImageResult> checkImageRequest = new CheckImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStackConverter.convert(stack), image);
LOGGER.info("Triggering event: {}", checkImageRequest);
eventBus.notify(checkImageRequest.selector(), eventFactory.createEvent(checkImageRequest));
CheckImageResult result = checkImageRequest.await();
sendNotification(result, stack);
LOGGER.info("Result: {}", result);
return result;
} catch (InterruptedException e) {
LOGGER.error("Error while executing check image", e);
throw new OperationException(e);
} catch (CloudbreakImageNotFoundException e) {
throw new CloudbreakServiceException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest in project cloudbreak by hortonworks.
the class CheckImageHandler method accept.
@Override
public void accept(Event<CheckImageRequest> event) {
LOGGER.info("Received event: {}", event);
CheckImageRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
AuthenticatedContext auth = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
Image image = request.getImage();
CloudStack stack = request.getStack();
ImageStatusResult progress = connector.setup().checkImageStatus(auth, stack, image);
CheckImageResult imageResult = new CheckImageResult(request, progress.getImageStatus(), progress.getStatusProgressValue());
request.getResult().onNext(imageResult);
LOGGER.info("Provision setup finished for {}", cloudContext);
} catch (RuntimeException e) {
CheckImageResult failure = new CheckImageResult(e, request, ImageStatus.CREATE_FAILED);
request.getResult().onNext(failure);
}
}
Aggregations