Search in sources :

Example 1 with ImageCatalogPlatform

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;
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) LoggerFactory(org.slf4j.LoggerFactory) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ClouderaManagerProductsProvider(com.sequenceiq.cloudbreak.cluster.service.ClouderaManagerProductsProvider) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Service(org.springframework.stereotype.Service) Map(java.util.Map) ClouderaManagerProductV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request) CDH_PRODUCT_DETAILS(com.sequenceiq.cloudbreak.common.type.ComponentType.CDH_PRODUCT_DETAILS) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Component(com.sequenceiq.cloudbreak.domain.stack.Component) NotFoundException.notFound(com.sequenceiq.cloudbreak.common.exception.NotFoundException.notFound) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) PlatformStringTransformer(com.sequenceiq.cloudbreak.service.image.PlatformStringTransformer) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) Logger(org.slf4j.Logger) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) Set(java.util.Set) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) IOException(java.io.IOException) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) StackType(com.sequenceiq.cloudbreak.cloud.model.component.StackType) ParcelFilterService(com.sequenceiq.cloudbreak.service.parcel.ParcelFilterService) Collectors(java.util.stream.Collectors) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Objects(java.util.Objects) Json(com.sequenceiq.cloudbreak.common.json.Json) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) List(java.util.List) BlueprintUtils(com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils) Optional(java.util.Optional) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) ImageBasedDefaultCDHEntries(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHEntries) Collections(java.util.Collections) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 2 with ImageCatalogPlatform

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);
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 3 with ImageCatalogPlatform

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;
}
Also used : Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) RepositoryInfo(com.sequenceiq.cloudbreak.cloud.model.component.RepositoryInfo) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) HashMap(java.util.HashMap) ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) StackType(com.sequenceiq.cloudbreak.cloud.model.component.StackType) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Inject(javax.inject.Inject) Service(org.springframework.stereotype.Service) Map(java.util.Map) Entry(java.util.Map.Entry) Optional(java.util.Optional) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Comparator(java.util.Comparator) ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response) Entry(java.util.Map.Entry) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)

Example 4 with ImageCatalogPlatform

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;
}
Also used : ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) StatedImages.statedImages(com.sequenceiq.cloudbreak.service.image.StatedImages.statedImages) StatedImage.statedImage(com.sequenceiq.cloudbreak.service.image.StatedImage.statedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog)

Example 5 with ImageCatalogPlatform

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());
}
Also used : StatedImages.statedImages(com.sequenceiq.cloudbreak.service.image.StatedImages.statedImages) Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) StatedImages(com.sequenceiq.cloudbreak.service.image.StatedImages) ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image)

Aggregations

ImageCatalogPlatform (com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform)19 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)10 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)6 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)6 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)5 Test (org.junit.jupiter.api.Test)5 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)4 Optional (java.util.Optional)4 Inject (javax.inject.Inject)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)3 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)3 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)3 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)3 StatedImages (com.sequenceiq.cloudbreak.service.image.StatedImages)3 ClouderaManagerStackDescriptorV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response)2 StackMatrixV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)2 Measure (com.sequenceiq.cloudbreak.aspect.Measure)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 StackType (com.sequenceiq.cloudbreak.cloud.model.component.StackType)2