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);
}
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();
}
}
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));
}
}
}
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));
}
}
}
}
Aggregations