Search in sources :

Example 36 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class StackToTemplatePreparationObjectConverterTest method testConvertWhenGeneralClusterConfigsProvidedThenThisShouldBeStored.

@Test
public void testConvertWhenGeneralClusterConfigsProvidedThenThisShouldBeStored() {
    GeneralClusterConfigs expected = mock(GeneralClusterConfigs.class);
    when(generalClusterConfigsProvider.generalClusterConfigs(stackMock, cluster)).thenReturn(expected);
    when(blueprintViewProvider.getBlueprintView(any())).thenReturn(getBlueprintView());
    TemplatePreparationObject result = underTest.convert(stackMock);
    assertThat(result.getGeneralClusterConfigs()).isEqualTo(expected);
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) Test(org.junit.jupiter.api.Test)

Example 37 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class StackV4RequestToTemplatePreparationObjectConverterTest method testConvertWhenObtainingGeneralClusterConfigsFromGeneralClusterConfigsProviderThenItsReturnValueShouldBeStored.

@Test
public void testConvertWhenObtainingGeneralClusterConfigsFromGeneralClusterConfigsProviderThenItsReturnValueShouldBeStored() {
    GeneralClusterConfigs expected = new GeneralClusterConfigs();
    when(generalClusterConfigsProvider.generalClusterConfigs(eq(source), anyString(), anyString())).thenReturn(expected);
    TemplatePreparationObject result = underTest.convert(source);
    assertEquals(expected, result.getGeneralClusterConfigs());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) Test(org.junit.Test)

Example 38 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class StackV4RequestToTemplatePreparationObjectConverter method convert.

public TemplatePreparationObject convert(StackV4Request source) {
    try {
        CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
        User user = userService.getOrCreate(cloudbreakUser);
        Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
        DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
        Credential credential = getCredential(source, environment);
        LdapView ldapConfig = getLdapConfig(source, environment);
        BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(source, credential.getAttributes());
        Set<RDSConfig> rdsConfigs = getRdsConfigs(source, workspace);
        Blueprint blueprint = getBlueprint(source, workspace);
        Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
        Gateway gateway = source.getCluster().getGateway() == null ? null : stackV4RequestToGatewayConverter.convert(source);
        BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(blueprint);
        Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
        GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, cloudbreakUser.getEmail(), blueprintService.getBlueprintVariant(blueprint));
        String gatewaySignKey = null;
        if (gateway != null) {
            gatewaySignKey = gateway.getSignKey();
        }
        String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
        VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapConfig != null ? ldapConfig.getAdminGroup() : "");
        Builder builder = Builder.builder().withCloudPlatform(source.getCloudPlatform()).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withLdapConfig(ldapConfig).withCustomInputs(source.getInputs()).withKerberosConfig(getKerberosConfig(source, environment)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
        decorateBuilderWithPlacement(source, builder);
        decorateBuilderWithAccountMapping(source, environment, credential, builder);
        decorateBuilderWithProductDetails(source, builder);
        decorateDatalakeView(source, builder);
        return builder.build();
    } catch (BlueprintProcessingException | IOException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    }
}
Also used : BlueprintProcessingException(com.sequenceiq.cloudbreak.template.BlueprintProcessingException) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) User(com.sequenceiq.cloudbreak.workspace.model.User) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) IOException(java.io.IOException) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 39 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class RangerRazDatahubConfigProviderTest method getAdditionalServicesWhenRazIsEnabledWithCm710.

@ParameterizedTest(name = "{0}")
@MethodSource("razCloudPlatformDataProvider")
@DisplayName("CM 7.1.0 DH is used and Raz is requested, no additional service needs to be added to the template")
void getAdditionalServicesWhenRazIsEnabledWithCm710(String testCaseName, CloudPlatform cloudPlatform) {
    ClouderaManagerRepo cmRepo = new ClouderaManagerRepo();
    cmRepo.setVersion("7.1.0");
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    HostgroupView master = new HostgroupView("master", 0, InstanceGroupType.GATEWAY, List.of());
    HostgroupView worker = new HostgroupView("worker", 0, InstanceGroupType.CORE, List.of());
    TemplatePreparationObject preparationObject = Builder.builder().withStackType(StackType.WORKLOAD).withCloudPlatform(cloudPlatform).withProductDetails(cmRepo, List.of()).withDataLakeView(new DatalakeView(true)).withGeneralClusterConfigs(generalClusterConfigs).withHostgroupViews(Set.of(master, worker)).build();
    Map<String, ApiClusterTemplateService> additionalServices = configProvider.getAdditionalServices(cmTemplateProcessor, preparationObject);
    assertEquals(0, additionalServices.size());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) DatalakeView(com.sequenceiq.cloudbreak.template.views.DatalakeView) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Example 40 with GeneralClusterConfigs

use of com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs in project cloudbreak by hortonworks.

the class RangerRazDatahubConfigProviderTest method getAdditionalServicesWhenRazIsEnabledAndDataLake.

@ParameterizedTest(name = "{0}")
@MethodSource("razCloudPlatformDataProvider")
@DisplayName("CM 7.2.0 DH is used and Raz is requested, but Data Lake, no additional service needs to be added to the template")
void getAdditionalServicesWhenRazIsEnabledAndDataLake(String testCaseName, CloudPlatform cloudPlatform) {
    ClouderaManagerRepo cmRepo = new ClouderaManagerRepo();
    cmRepo.setVersion("7.2.0");
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setEnableRangerRaz(true);
    HostgroupView master = new HostgroupView("master", 0, InstanceGroupType.GATEWAY, List.of());
    HostgroupView idbroker = new HostgroupView("idbroker", 0, InstanceGroupType.CORE, List.of());
    TemplatePreparationObject preparationObject = Builder.builder().withStackType(StackType.DATALAKE).withCloudPlatform(cloudPlatform).withProductDetails(cmRepo, List.of()).withGeneralClusterConfigs(generalClusterConfigs).withHostgroupViews(Set.of(master, idbroker)).build();
    Map<String, ApiClusterTemplateService> additionalServices = configProvider.getAdditionalServices(cmTemplateProcessor, preparationObject);
    assertEquals(0, additionalServices.size());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)67 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)52 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)28 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)21 Test (org.junit.jupiter.api.Test)20 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)19 Test (org.junit.Test)18 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)16 DisplayName (org.junit.jupiter.api.DisplayName)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)15 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 DatalakeView (com.sequenceiq.cloudbreak.template.views.DatalakeView)12 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)11 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 HashSet (java.util.HashSet)8 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)7 ArrayList (java.util.ArrayList)7 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)6