Search in sources :

Example 91 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class CmHostGroupRoleConfigProviderProcessor method generateConfigs.

@VisibleForTesting
Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) {
    Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>();
    Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity()));
    List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor);
    Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents();
    for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) {
        String hostGroupName = hostTemplate.getRefName();
        List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of);
        HostgroupView hostgroupView = hostGroups.get(hostGroupName);
        groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView);
    }
    return configsByRoleConfigGroup;
}
Also used : HashMap(java.util.HashMap) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ArrayList(java.util.ArrayList) List(java.util.List) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) HashMap(java.util.HashMap) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) ApiClusterTemplateHostTemplate(com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 92 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig 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 93 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class KnoxIdBrokerConfigProvider method getRoleConfigs.

@Override
protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) {
    switch(roleType) {
        case IDBROKER:
            List<ApiClusterTemplateConfig> config;
            AccountMappingView accountMappingView = source.getAccountMappingView() == null ? AccountMappingView.EMPTY_MAPPING : source.getAccountMappingView();
            String userMappings = getAccountMappingSetting(accountMappingView.getUserMappings());
            String groupMappings = getAccountMappingSetting(accountMappingView.getGroupMappings());
            switch(getCloudPlatform(source)) {
                case AWS:
                    config = List.of(config("idbroker_aws_user_mapping", userMappings), config("idbroker_aws_group_mapping", groupMappings));
                    break;
                case AZURE:
                    config = new ArrayList<>(List.of(config("idbroker_azure_user_mapping", userMappings), config("idbroker_azure_group_mapping", groupMappings)));
                    ClouderaManagerRepo cmRepo = source.getProductDetailsView().getCm();
                    if (CMRepositoryVersionUtil.isIdBrokerManagedIdentitySupported(cmRepo)) {
                        String idBrokerManagedIdentity = getIdBrokerManagedIdentity(source.getFileSystemConfigurationView());
                        if (Objects.nonNull(idBrokerManagedIdentity)) {
                            config.add(config("idbroker_azure_vm_assumer_identity", idBrokerManagedIdentity));
                        }
                    }
                    break;
                case GCP:
                    config = List.of(config("idbroker_gcp_user_mapping", userMappings), config("idbroker_gcp_group_mapping", groupMappings));
                    break;
                default:
                    config = List.of();
                    break;
            }
            return config;
        default:
            return List.of();
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView)

Example 94 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class KnoxServiceConfigProvider method getServiceConfigs.

@Override
public List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) {
    List<ApiClusterTemplateConfig> configList = new ArrayList<>();
    if (source.getProductDetailsView() != null && isKnoxDatabaseSupported(source.getProductDetailsView().getCm(), getCdhProduct(source), getCdhPatchVersion(source))) {
        RdsView knoxGatewayRdsView = getRdsView(source);
        configList.add(config(DATABASE_TYPE, knoxGatewayRdsView.getSubprotocol()));
        configList.add(config(DATABASE_NAME, knoxGatewayRdsView.getDatabaseName()));
        configList.add(config(DATABASE_HOST, knoxGatewayRdsView.getHost()));
        configList.add(config(DATABASE_PORT, knoxGatewayRdsView.getPort()));
        configList.add(config(DATABASE_USER, knoxGatewayRdsView.getConnectionUserName()));
        configList.add(config(DATABASE_PASSWORD, knoxGatewayRdsView.getConnectionPassword()));
    }
    configList.add(config(KNOX_AUTORESTART_ON_STOP, Boolean.TRUE.toString()));
    return configList;
}
Also used : RdsView(com.sequenceiq.cloudbreak.template.views.RdsView) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig)

Example 95 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class NifiConfigProvider method getServiceConfigs.

@Override
public List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) {
    List<ApiClusterTemplateConfig> configList = new ArrayList<>();
    String cdhVersion = source.getBlueprintView().getProcessor().getStackVersion() == null ? "" : source.getBlueprintView().getProcessor().getStackVersion();
    if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_1_0)) {
        VirtualGroupRequest virtualGroupRequest = source.getVirtualGroupRequest();
        String adminGroup = virtualGroupService.createOrGetVirtualGroup(virtualGroupRequest, UmsVirtualGroupRight.NIFI_ADMIN);
        configList.add(config("nifi.initial.admin.groups", adminGroup));
        rangerAutoCompleteConfigProvider.extendServiceConfigs(source, configList);
    }
    return configList;
}
Also used : VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig)

Aggregations

ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)172 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)129 Test (org.junit.Test)78 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)74 Test (org.junit.jupiter.api.Test)57 ArrayList (java.util.ArrayList)55 List (java.util.List)50 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)25 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)22 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)21 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)18 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)17 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)17 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)13 AccountMappingView (com.sequenceiq.cloudbreak.template.views.AccountMappingView)13 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)12 HashMap (java.util.HashMap)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)9 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)8