use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method getDefaultCDHInfo.
private DefaultCDHInfo getDefaultCDHInfo(Cluster cluster, String blueprintCdhVersion, String osType, String imageCatalogName) throws CloudbreakImageCatalogException {
DefaultCDHInfo defaultCDHInfo = null;
Stack stack = cluster.getStack();
ImageCatalogPlatform platformString = platformStringTransformer.getPlatformStringForImageCatalog(stack.getCloudPlatform(), stack.getPlatformVariant());
Map<String, ImageBasedDefaultCDHInfo> entries = imageBasedDefaultCDHEntries.getEntries(cluster.getWorkspace().getId(), platformString, imageCatalogName);
if (blueprintCdhVersion != null && entries.containsKey(blueprintCdhVersion)) {
defaultCDHInfo = entries.get(blueprintCdhVersion).getDefaultCDHInfo();
}
if (defaultCDHInfo == null) {
defaultCDHInfo = entries.entrySet().stream().filter(e -> Objects.nonNull(e.getValue().getDefaultCDHInfo().getRepo().getStack().get(osType))).max(ImageBasedDefaultCDHEntries.IMAGE_BASED_CDH_ENTRY_COMPARATOR).orElseThrow(notFound("Default Product Info with OS type:", osType)).getValue().getDefaultCDHInfo();
}
return defaultCDHInfo;
}
use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method determineCmRepoConfig.
private ClusterComponent determineCmRepoConfig(Optional<Component> stackClouderaManagerRepoConfig, String osType, Cluster cluster, String cdhStackVersion) throws CloudbreakImageCatalogException {
Json json;
if (Objects.isNull(stackClouderaManagerRepoConfig) || stackClouderaManagerRepoConfig.isEmpty()) {
ImageCatalogPlatform platform = platformStringTransformer.getPlatformStringForImageCatalog(cluster.getStack().getCloudPlatform(), cluster.getStack().getPlatformVariant());
ClouderaManagerRepo clouderaManagerRepo = defaultClouderaManagerRepoService.getDefault(osType, StackType.CDH.name(), cdhStackVersion, platform);
if (clouderaManagerRepo == null) {
throw new BadRequestException(String.format("Couldn't determine Cloudera Manager repo for the stack: %s", cluster.getStack().getName()));
}
json = new Json(clouderaManagerRepo);
} else {
json = stackClouderaManagerRepoConfig.get().getAttributes();
}
return new ClusterComponent(ComponentType.CM_REPO_DETAILS, json, cluster);
}
use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class DefaultClouderaManagerRepoService method getDefault.
public ClouderaManagerRepo getDefault(String osType, String clusterType, String clusterVersion, ImageCatalogPlatform platform) throws CloudbreakImageCatalogException {
if (StackType.CDH.name().equals(clusterType)) {
StackMatrixV4Response stackMatrixV4Response = stackMatrixService.getStackMatrix(platform);
Map<String, ClouderaManagerStackDescriptorV4Response> stackDescriptorMap = stackMatrixV4Response.getCdh();
if (stackDescriptorMap != null) {
Optional<Entry<String, ClouderaManagerStackDescriptorV4Response>> descriptorEntry = stackDescriptorMap.entrySet().stream().filter(stackDescriptorEntry -> clusterVersion == null || clusterVersion.equals(stackDescriptorEntry.getKey())).max(Comparator.comparing(Entry::getKey));
if (descriptorEntry.isPresent()) {
Entry<String, ClouderaManagerStackDescriptorV4Response> stackDescriptorEntry = descriptorEntry.get();
ClouderaManagerInfoV4Response clouderaManagerInfoJson = stackDescriptorEntry.getValue().getClouderaManager();
if (clouderaManagerInfoJson.getRepository().get(osType) != null) {
ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
clouderaManagerRepo.setPredefined(false);
clouderaManagerRepo.setVersion(clouderaManagerInfoJson.getVersion());
clouderaManagerRepo.setBaseUrl(clouderaManagerInfoJson.getRepository().get(osType).getBaseUrl());
clouderaManagerRepo.setGpgKeyUrl(clouderaManagerInfoJson.getRepository().get(osType).getGpgKeyUrl());
return clouderaManagerRepo;
}
}
}
}
LOGGER.info("Missing Cloudera Manager Repo information for os: {} clusterType: {} clusterVersion: {}", osType, clusterType, clusterVersion);
return null;
}
use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class ImageCatalogService method getStatedImagesFilteredByOperatingSystems.
public StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate) throws CloudbreakImageCatalogException {
Set<ImageCatalogPlatform> platforms = imageFilter.getPlatforms();
Set<String> operatingSystems = imageFilter.getOperatingSystems();
ImageCatalog imageCatalog = imageFilter.getImageCatalog();
boolean baseImageEnabled = imageFilter.isBaseImageEnabled();
StatedImages images = getImages(new ImageFilter(imageCatalog, platforms, cbVersion, baseImageEnabled, null, null));
if (!CollectionUtils.isEmpty(operatingSystems)) {
Images rawImages = images.getImages();
List<Image> baseImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getBaseImages(), operatingSystems, imageFilterPredicate);
List<Image> cdhImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getCdhImages(), operatingSystems, imageFilterPredicate);
images = statedImages(new Images(baseImages, cdhImages, rawImages.getFreeIpaImages(), rawImages.getSuppertedVersions()), images.getImageCatalogUrl(), images.getImageCatalogName());
}
return images;
}
use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class RawImageProvider method getImages.
public StatedImages getImages(CloudbreakImageCatalogV3 imageCatalogV3, ImageFilter imageFilter) {
Images catalogImages = imageCatalogV3.getImages();
Set<ImageCatalogPlatform> platforms = imageFilter.getPlatforms();
List<Image> baseImages = filterImagesByPlatforms(platforms, catalogImages.getBaseImages());
List<Image> cdhImages = filterImagesByPlatforms(platforms, catalogImages.getCdhImages());
List<Image> freeipaImages = filterImagesByPlatforms(platforms, catalogImages.getFreeIpaImages());
return statedImages(new Images(baseImages, cdhImages, freeipaImages, catalogImages.getSuppertedVersions()), imageFilter.getImageCatalog().getImageCatalogUrl(), imageFilter.getImageCatalog().getName());
}
Aggregations