use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class StackImageService method changeImageCatalog.
public void changeImageCatalog(Stack stack, String imageCatalog) {
try {
Image currentImage = componentConfigProviderService.getImage(stack.getId());
ImageCatalog targetImageCatalog = imageCatalogService.getImageCatalogByName(stack.getWorkspace().getId(), imageCatalog);
StatedImage targetImage = imageCatalogService.getImage(targetImageCatalog.getImageCatalogUrl(), targetImageCatalog.getName(), currentImage.getImageId());
replaceStackImageComponent(stack, targetImage);
} catch (IllegalArgumentException e) {
LOGGER.error("Failed to change the image catalog.", e);
throw new CloudbreakServiceException("Failed to change the image catalog.");
} catch (CloudbreakImageNotFoundException e) {
LOGGER.error(e.getMessage(), e);
throw new NotFoundException(e.getMessage());
} catch (CloudbreakImageCatalogException e) {
LOGGER.error("Failed to replace stack image component", e);
throw new CloudbreakServiceException(e.getMessage());
}
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class StackImageService method getImageModelFromStatedImage.
public Image getImageModelFromStatedImage(Stack stack, Image currentImage, StatedImage targetImage) {
try {
ImageCatalogPlatform platformString = platformStringTransformer.getPlatformStringForImageCatalog(stack.getCloudPlatform(), stack.getPlatformVariant());
String cloudPlatform = platform(stack.cloudPlatform()).value().toLowerCase();
String newImageName = imageService.determineImageName(cloudPlatform, platformString, stack.getRegion(), targetImage.getImage());
return new Image(newImageName, currentImage.getUserdata(), targetImage.getImage().getOs(), targetImage.getImage().getOsType(), targetImage.getImageCatalogUrl(), targetImage.getImageCatalogName(), targetImage.getImage().getUuid(), targetImage.getImage().getPackageVersions());
} catch (CloudbreakImageNotFoundException e) {
LOGGER.info("Could not find image", e);
throw new CloudbreakServiceException("Could not find image", e);
}
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class ClusterUpgradeDiskSpaceValidationHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeValidationEvent> event) {
LOGGER.debug("Accepting Cluster upgrade validation event.");
ClusterUpgradeValidationEvent request = event.getData();
Long stackId = request.getResourceId();
try {
StatedImage targetImage = imageService.getCurrentImage(stackId);
diskSpaceValidationService.validateFreeSpaceForUpgrade(getStack(stackId), targetImage);
return new ClusterUpgradeDiskSpaceValidationFinishedEvent(request.getResourceId());
} catch (UpgradeValidationFailedException e) {
LOGGER.warn("Cluster upgrade validation failed", e);
return new ClusterUpgradeValidationFailureEvent(stackId, e);
} catch (Exception e) {
LOGGER.error("Cluster upgrade validation was unsuccessful due to an internal error", e);
return new ClusterUpgradeDiskSpaceValidationFinishedEvent(request.getResourceId());
}
}
Aggregations