Search in sources :

Example 1 with DefaultCDHInfo

use of com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo in project cloudbreak by hortonworks.

the class ClouderaManagerClusterCreationSetupService method getDefaultCDHInfo.

private DefaultCDHInfo getDefaultCDHInfo(Long workspaceId, String blueprintCdhVersion, String osType, String cloudPlatform, String imageCatalogName) throws CloudbreakImageCatalogException {
    DefaultCDHInfo defaultCDHInfo = null;
    Map<String, ImageBasedDefaultCDHInfo> entries = imageBasedDefaultCDHEntries.getEntries(workspaceId, cloudPlatform, 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 : 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) 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) 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) 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) Sets(com.google.common.collect.Sets) 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) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo)

Example 2 with DefaultCDHInfo

use of com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo in project cloudbreak by hortonworks.

the class ClouderaManagerClusterCreationSetupService method determineCdhRepoConfig.

private Set<ClouderaManagerProduct> determineCdhRepoConfig(Cluster cluster, List<Component> stackCdhRepoConfig, String osType, String blueprintCdhVersion, String imageCatalogName) throws CloudbreakImageCatalogException {
    if (Objects.isNull(stackCdhRepoConfig) || stackCdhRepoConfig.isEmpty()) {
        DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(cluster, blueprintCdhVersion, osType, imageCatalogName);
        Map<String, String> stack = defaultCDHInfo.getRepo().getStack();
        Set<ClouderaManagerProduct> cdhProduct = Set.of(new ClouderaManagerProduct().withVersion(defaultCDHInfo.getVersion()).withName(stack.get("repoid").split("-")[0]).withParcel(stack.get(osType)));
        LOGGER.debug("Determined CDH product: {}", cdhProduct);
        return cdhProduct;
    } else {
        Set<ClouderaManagerProduct> products = stackCdhRepoConfig.stream().map(Component::getAttributes).map(json -> json.getSilent(ClouderaManagerProduct.class)).collect(Collectors.toSet());
        return filterParcelsIfNecessary(cluster, products);
    }
}
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) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Component(com.sequenceiq.cloudbreak.domain.stack.Component) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)

Example 3 with DefaultCDHInfo

use of com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo 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 4 with DefaultCDHInfo

use of com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo in project cloudbreak by hortonworks.

the class ImagesToImagesV4ResponseConverterTest method setupStackEntries.

private void setupStackEntries() {
    Map<String, ImageBasedDefaultCDHInfo> cdhEntries = new HashMap<>();
    DefaultCDHInfo cdhInfo = getDefaultCDHInfo("6.1.0-1.cdh6.1.0.p0.770702");
    Image image = mock(Image.class);
    cdhEntries.put("6.1.0", new ImageBasedDefaultCDHInfo(cdhInfo, image));
    when(imageBasedDefaultCDHEntries.getEntries(Mockito.any(Images.class))).thenReturn(cdhEntries);
}
Also used : ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) RepoTestUtil.getDefaultCDHInfo(com.sequenceiq.cloudbreak.RepoTestUtil.getDefaultCDHInfo) HashMap(java.util.HashMap) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image)

Example 5 with DefaultCDHInfo

use of com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo in project cloudbreak by hortonworks.

the class ClusterCreationSetupServiceTest method init.

@Before
public void init() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException, IOException {
    MockitoAnnotations.initMocks(this);
    workspace = new Workspace();
    clusterRequest = new ClusterV4Request();
    stack = new Stack();
    stack.setId(1L);
    stack.setWorkspace(workspace);
    stack.setEnvironmentCrn("env");
    stack.setName("name");
    blueprint = new Blueprint();
    blueprint.setBlueprintText("{}");
    user = new User();
    Map<InstanceGroupType, String> userData = new HashMap<>();
    userData.put(InstanceGroupType.CORE, "userdata");
    Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", "imgcatname", "id", Collections.emptyMap());
    Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
    cluster = new Cluster();
    stack.setCluster(cluster);
    when(clusterDecorator.decorate(any(), any(), any(), any(), any(), any())).thenReturn(cluster);
    when(componentConfigProviderService.getAllComponentsByStackIdAndType(any(), any())).thenReturn(Sets.newHashSet(imageComponent));
    when(blueprintUtils.getBlueprintStackVersion(any())).thenReturn(HDP_VERSION);
    when(blueprintUtils.getBlueprintStackName(any())).thenReturn("HDP");
    DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(CDH_VERSION);
    when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(Collections.singletonMap(CDH_VERSION, new ImageBasedDefaultCDHInfo(defaultCDHInfo, Mockito.mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class))));
    when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
    StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
    stackMatrixV4Response.setCdh(Collections.singletonMap(CDH_VERSION, null));
    when(stackMatrixService.getStackMatrix(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(stackMatrixV4Response);
    when(clouderaManagerClusterCreationSetupService.prepareClouderaManagerCluster(any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) RepoTestUtil.getDefaultCDHInfo(com.sequenceiq.cloudbreak.RepoTestUtil.getDefaultCDHInfo) Component(com.sequenceiq.cloudbreak.domain.stack.Component) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Before(org.junit.Before)

Aggregations

DefaultCDHInfo (com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo)11 ImageBasedDefaultCDHInfo (com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo)8 StackMatrixV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)6 ClouderaManagerStackDescriptorV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response)5 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)4 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)4 Image (com.sequenceiq.cloudbreak.cloud.model.Image)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 Component (com.sequenceiq.cloudbreak.domain.stack.Component)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Inject (javax.inject.Inject)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 ClouderaManagerV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request)3 ClouderaManagerProductV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request)3 ClouderaManagerRepositoryV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request)3 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)3