Search in sources :

Example 46 with ClouderaManagerProduct

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

the class CmTemplateValidatorTest method testValidationIfNifi728PresentedAndDownScaleThenValidationShouldThrowException.

@Test
public void testValidationIfNifi728PresentedAndDownScaleThenValidationShouldThrowException() {
    Blueprint blueprint = readBlueprint("input/nifi_7_2_8.bp");
    String hostGroup = "master";
    ClouderaManagerProduct clouderaManagerRepo = new ClouderaManagerProduct();
    clouderaManagerRepo.setVersion("7.2.8");
    when(entitlementService.isEntitledFor(anyString(), any())).thenReturn(true);
    assertDoesNotThrow(() -> subject.validateHostGroupScalingRequest(ACCOUNT_ID, blueprint, Optional.of(clouderaManagerRepo), hostGroup, -2, List.of()));
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 47 with ClouderaManagerProduct

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

the class KnoxGatewayConfigProvider method getDefaultsIfRequired.

private Set<ApiClusterTemplateConfig> getDefaultsIfRequired(TemplatePreparationObject source) {
    Set<ApiClusterTemplateConfig> apiClusterTemplateConfigs = new HashSet<>();
    Optional<ClouderaManagerProduct> cdhProduct = getCdhProduct(source);
    if (cdhProduct.isPresent() && source.getProductDetailsView() != null) {
        String cdhVersion = cdhProduct.get().getVersion().split("-")[0];
        ClouderaManagerRepo clouderaManagerRepoDetails = source.getProductDetailsView().getCm();
        if (tokenServiceSupported(cdhVersion, clouderaManagerRepoDetails)) {
            Optional<String> accountId = source.getGeneralClusterConfigs().getAccountId();
            if (accountId.isPresent() && !entitlementService.isOjdbcTokenDhOneHour(accountId.get())) {
                apiClusterTemplateConfigs.add(config(GATEWAY_TOKEN_GENERATION_KNOX_TOKEN_TTL, GATEWAY_TOKEN_GENERATION_KNOX_TOKEN_TTL_ONE_DAY));
                apiClusterTemplateConfigs.add(config(GATEWAY_TOKEN_GENERATION_ENABLE_LIFESPAN_INPUT, GATEWAY_TOKEN_GENERATION_ENABLE_LIFESPAN_INPUT_TRUE));
            }
        }
    }
    return apiClusterTemplateConfigs;
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) HashSet(java.util.HashSet)

Example 48 with ClouderaManagerProduct

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

the class ImageFilterParamsFactory method getStackRelatedParcels.

public Map<String, String> getStackRelatedParcels(Stack stack) {
    Set<ClusterComponent> componentsByBlueprint = parcelService.getParcelComponentsByBlueprint(stack);
    if (stack.isDatalake()) {
        ClouderaManagerProduct stackProduct = getCdhProduct(componentsByBlueprint);
        LOGGER.debug("For datalake clusters only the CDH parcel is related in CM: {}", stackProduct);
        return Map.of(stackProduct.getName(), stackProduct.getVersion());
    } else {
        Set<ClouderaManagerProduct> products = clouderaManagerProductsProvider.getProducts(componentsByBlueprint);
        LOGGER.debug("The following parcels are related for this datahub cluster: {}", products);
        return products.stream().collect(Collectors.toMap(ClouderaManagerProduct::getName, ClouderaManagerProduct::getVersion));
    }
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Example 49 with ClouderaManagerProduct

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

the class ClouderaManagerParcelDecommissionServiceTest method testRemoveUnusedParcelVersions.

@Test
public void testRemoveUnusedParcelVersions() throws ApiException {
    Stack stack = mock(Stack.class);
    when(stack.getName()).thenReturn(STACK_NAME);
    ClouderaManagerProduct currentProductWithVersionToKeep = new ClouderaManagerProduct().withName("CDH").withVersion("current");
    doReturn(List.of(new ApiParcel().product("ignored").version("current"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old2"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version(currentProductWithVersionToKeep.getVersion()))).when(parcelManagementService).getClouderaManagerParcelsByStatus(parcelsResourceApi, STACK_NAME, ParcelStatus.DISTRIBUTED);
    ArgumentCaptor<Multimap<String, String>> parcelVersionsCaptorForDownloaded = ArgumentCaptor.forClass(Multimap.class);
    when(clouderaManagerPollingServiceProvider.startPollingCmParcelStatus(eq(stack), eq(apiClient), parcelVersionsCaptorForDownloaded.capture(), eq(ParcelStatus.DOWNLOADED))).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
    doReturn(List.of(new ApiParcel().product("ignored").version("current"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old2"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version(currentProductWithVersionToKeep.getVersion()))).when(parcelManagementService).getClouderaManagerParcelsByStatus(parcelsResourceApi, STACK_NAME, ParcelStatus.DOWNLOADED);
    ArgumentCaptor<Multimap<String, String>> parcelVersionsCaptorForDelete = ArgumentCaptor.forClass(Multimap.class);
    when(clouderaManagerPollingServiceProvider.startPollingCmParcelDelete(eq(stack), eq(apiClient), parcelVersionsCaptorForDelete.capture())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
    underTest.removeUnusedParcelVersions(apiClient, parcelsResourceApi, parcelResourceApi, stack, currentProductWithVersionToKeep);
    verify(parcelResourceApi).startRemovalOfDistributionCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old");
    verify(parcelResourceApi).startRemovalOfDistributionCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old2");
    assertEquals(2, parcelVersionsCaptorForDownloaded.getValue().size());
    assertTrue(parcelVersionsCaptorForDownloaded.getValue().containsEntry("CDH", "old"));
    assertTrue(parcelVersionsCaptorForDownloaded.getValue().containsEntry("CDH", "old2"));
    verify(parcelResourceApi).removeDownloadCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old");
    verify(parcelResourceApi).removeDownloadCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old2");
    assertEquals(2, parcelVersionsCaptorForDelete.getValue().size());
    assertTrue(parcelVersionsCaptorForDelete.getValue().containsEntry("CDH", "old"));
    assertTrue(parcelVersionsCaptorForDelete.getValue().containsEntry("CDH", "old2"));
    verifyNoMoreInteractions(parcelResourceApi);
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) Multimap(com.google.common.collect.Multimap) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 50 with ClouderaManagerProduct

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

the class ImageService method createProductRepo.

private ClouderaManagerProduct createProductRepo(ImageStackDetails stack, String osType) {
    ClouderaManagerProduct cmProduct = new ClouderaManagerProduct();
    Map<String, String> stackInfo = stack.getRepo().getStack();
    cmProduct.withVersion(stackInfo.get(StackRepoDetails.REPOSITORY_VERSION)).withName(stackInfo.get(StackRepoDetails.REPO_ID_TAG).split("-")[0]).withParcel(stackInfo.get(osType));
    return cmProduct;
}
Also used : ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Aggregations

ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)91 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)23 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)20 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)14 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)10 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)9 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)9 ParcelInfo (com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo)9 HashSet (java.util.HashSet)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)7 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)6 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)6 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)6 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)6 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)6 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)5