Search in sources :

Example 1 with GatewayView

use of com.sequenceiq.cloudbreak.template.views.GatewayView in project cloudbreak by hortonworks.

the class CentralCmTemplateUpdaterTest method getKafkaPropertiesWhenNoHdfsInClusterShouldPresentCoreSettings.

@Test
public void getKafkaPropertiesWhenNoHdfsInClusterShouldPresentCoreSettings() {
    CoreConfigProvider coreConfigProvider = new CoreConfigProvider();
    ReflectionTestUtils.setField(coreConfigProvider, "s3ConfigProvider", s3ConfigProvider);
    List<CmTemplateComponentConfigProvider> cmTemplateComponentConfigProviders = List.of(coreConfigProvider);
    ReflectionTestUtils.setField(cmTemplateComponentConfigProviderProcessor, "providers", cmTemplateComponentConfigProviders);
    S3FileSystem s3FileSystem = new S3FileSystem();
    s3FileSystem.setInstanceProfile("profile");
    s3FileSystem.setS3GuardDynamoTableName("cb-table");
    s3FileSystem.setStorageContainer("cloudbreak-bucket");
    StorageLocation storageLocation = new StorageLocation();
    storageLocation.setProperty("core_defaultfs");
    storageLocation.setValue("s3a://cloudbreak-bucket/kafka");
    storageLocation.setConfigFile("core_settings");
    StorageLocationView storageLocationView = new StorageLocationView(storageLocation);
    BaseFileSystemConfigurationsView baseFileSystemConfigurationsView = new S3FileSystemConfigurationsView(s3FileSystem, Sets.newHashSet(storageLocationView), false);
    when(templatePreparationObject.getFileSystemConfigurationView()).thenReturn(Optional.of(baseFileSystemConfigurationsView));
    when(templatePreparationObject.getGatewayView()).thenReturn(new GatewayView(new Gateway(), "signkey", new HashSet<>()));
    Set<HostgroupView> hostgroupViews = new HashSet<>();
    hostgroupViews.add(new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1));
    when(templatePreparationObject.getHostgroupViews()).thenReturn(hostgroupViews);
    when(templatePreparationObject.getGatewayView()).thenReturn(new GatewayView(new Gateway(), "signkey", new HashSet<>()));
    when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/kafka-without-hdfs.bp"));
    String generated = generator.getBlueprintText(templatePreparationObject);
    String expected = new CmTemplateProcessor(getBlueprintText("output/kafka-without-hdfs.bp")).getTemplate().toString();
    String output = new CmTemplateProcessor(generated).getTemplate().toString();
    Assert.assertEquals(expected, output);
}
Also used : StorageLocationView(com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView) CoreConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.core.CoreConfigProvider) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) S3FileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView) S3FileSystem(com.sequenceiq.common.api.filesystem.S3FileSystem) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) StorageLocation(com.sequenceiq.cloudbreak.domain.StorageLocation) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) GatewayView(com.sequenceiq.cloudbreak.template.views.GatewayView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with GatewayView

use of com.sequenceiq.cloudbreak.template.views.GatewayView in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProvider method getRoleConfigs.

@Override
protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) {
    GatewayView gateway = source.getGatewayView();
    GeneralClusterConfigs generalClusterConfigs = source.getGeneralClusterConfigs();
    String masterSecret = gateway != null ? gateway.getMasterSecret() : generalClusterConfigs.getPassword();
    String topologyName = gateway != null && gateway.getExposedServices() != null ? gateway.getTopologyName() : DEFAULT_TOPOLOGY;
    VirtualGroupRequest virtualGroupRequest = source.getVirtualGroupRequest();
    String adminGroup = virtualGroupService.createOrGetVirtualGroup(virtualGroupRequest, UmsVirtualGroupRight.KNOX_ADMIN);
    switch(roleType) {
        case KnoxRoles.KNOX_GATEWAY:
            List<ApiClusterTemplateConfig> config = new ArrayList<>();
            config.add(config(KNOX_MASTER_SECRET, masterSecret));
            config.add(config(GATEWAY_DEFAULT_TOPOLOGY_NAME, topologyName));
            config.add(config(GATEWAY_ADMIN_GROUPS, adminGroup));
            config.add(config(GATEWAY_CM_AUTO_DISCOVERY_ENABLED, "false"));
            if (gateway != null) {
                config.add(config(GATEWAY_PATH, gateway.getPath()));
                config.add(config(GATEWAY_SIGNING_KEYSTORE_NAME, SIGNING_JKS));
                config.add(config(GATEWAY_SIGNING_KEYSTORE_TYPE, JKS));
                config.add(config(GATEWAY_SIGNING_KEY_ALIAS, SIGNING_IDENTITY));
                config.add(getGatewayWhitelistConfig(source));
                config.addAll(getDefaultsIfRequired(source));
            }
            if (source.getProductDetailsView() != null && isKnoxDatabaseSupported(source.getProductDetailsView().getCm(), getCdhProduct(source), getCdhPatchVersion(source))) {
                config.add(config(GATEWAY_SERVICE_TOKENSTATE_IMPL, "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService"));
            }
            return config;
        case KnoxRoles.IDBROKER:
            return List.of(config(IDBROKER_MASTER_SECRET, source.getIdBroker().getMasterSecret()), config(IDBROKER_GATEWAY_ADMIN_GROUPS, adminGroup), config(IDBROKER_SIGNING_KEYSTORE_NAME, SIGNING_JKS), config(IDBROKER_SIGNING_KEYSTORE_TYPE, JKS), config(IDBROKER_SIGNING_KEY_ALIAS, SIGNING_IDENTITY));
        default:
            return List.of();
    }
}
Also used : GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) GatewayView(com.sequenceiq.cloudbreak.template.views.GatewayView)

Example 3 with GatewayView

use of com.sequenceiq.cloudbreak.template.views.GatewayView in project cloudbreak by hortonworks.

the class HueConfigProvider method configureKnoxProxyHostsServiceConfig.

private void configureKnoxProxyHostsServiceConfig(TemplatePreparationObject source, List<ApiClusterTemplateConfig> result) {
    GatewayView gateway = source.getGatewayView();
    String cdhVersion = getCdhVersionString(source);
    GeneralClusterConfigs generalClusterConfigs = source.getGeneralClusterConfigs();
    if (externalFQDNShouldConfigured(gateway, generalClusterConfigs)) {
        // CDPD version 7.1.0 and above have a dedicated knox_proxyhosts property to set the knox proxy hosts.
        if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_1_0)) {
            result.add(new ApiClusterTemplateConfig().name(KNOX_PROXYHOSTS).variable(HUE_KNOX_PROXYHOSTS));
        } else {
            result.add(new ApiClusterTemplateConfig().name("hue_service_safety_valve").variable(HUE_SAFETY_VALVE));
        }
    }
}
Also used : GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) GatewayView(com.sequenceiq.cloudbreak.template.views.GatewayView)

Example 4 with GatewayView

use of com.sequenceiq.cloudbreak.template.views.GatewayView in project cloudbreak by hortonworks.

the class HueConfigProvider method configureKnoxProxyHostsConfigVariables.

private void configureKnoxProxyHostsConfigVariables(TemplatePreparationObject source, List<ApiClusterTemplateVariable> result) {
    GatewayView gateway = source.getGatewayView();
    String cdhVersion = getCdhVersionString(source);
    GeneralClusterConfigs generalClusterConfigs = source.getGeneralClusterConfigs();
    if (externalFQDNShouldConfigured(gateway, generalClusterConfigs)) {
        Set<String> proxyHosts = new HashSet<>();
        if (generalClusterConfigs.getPrimaryGatewayInstanceDiscoveryFQDN().isPresent()) {
            proxyHosts.add(generalClusterConfigs.getPrimaryGatewayInstanceDiscoveryFQDN().get());
        }
        if (StringUtils.isNotEmpty(generalClusterConfigs.getExternalFQDN())) {
            proxyHosts.add(generalClusterConfigs.getExternalFQDN());
        }
        if (generalClusterConfigs.getLoadBalancerGatewayFqdn().isPresent()) {
            proxyHosts.add(generalClusterConfigs.getLoadBalancerGatewayFqdn().get());
        }
        if (!proxyHosts.isEmpty()) {
            String proxyHostsString = String.join(",", proxyHosts);
            if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_1_0)) {
                LOGGER.debug("Using {} settings of [{}]", HUE_KNOX_PROXYHOSTS, proxyHostsString);
                result.add(new ApiClusterTemplateVariable().name(HUE_KNOX_PROXYHOSTS).value(proxyHostsString));
            } else {
                LOGGER.debug("Adding knox proxy hosts [{}] to {}", proxyHostsString, HUE_SAFETY_VALVE);
                String valveValue = SAFETY_VALVE_KNOX_PROXYHOSTS_KEY_PATTERN.concat(proxyHostsString);
                result.add(new ApiClusterTemplateVariable().name(HUE_SAFETY_VALVE).value(valveValue));
            }
        }
    }
}
Also used : GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ApiClusterTemplateVariable(com.cloudera.api.swagger.model.ApiClusterTemplateVariable) GatewayView(com.sequenceiq.cloudbreak.template.views.GatewayView) HashSet(java.util.HashSet)

Aggregations

GatewayView (com.sequenceiq.cloudbreak.template.views.GatewayView)4 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)3 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)2 HashSet (java.util.HashSet)2 ApiClusterTemplateVariable (com.cloudera.api.swagger.model.ApiClusterTemplateVariable)1 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)1 CoreConfigProvider (com.sequenceiq.cloudbreak.cmtemplate.configproviders.core.CoreConfigProvider)1 StorageLocation (com.sequenceiq.cloudbreak.domain.StorageLocation)1 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)1 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)1 StorageLocationView (com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView)1 S3FileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView)1 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)1 S3FileSystem (com.sequenceiq.common.api.filesystem.S3FileSystem)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1