use of com.sequenceiq.cloudbreak.dto.KerberosConfig in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method createSaltConfig.
private SaltConfig createSaltConfig(Stack stack, Cluster cluster, List<GrainProperties> grainsProperties) throws IOException, CloudbreakOrchestratorException {
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
ClouderaManagerRepo clouderaManagerRepo = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
KerberosConfig kerberosConfig = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()).orElse(null);
saveCustomNameservers(stack, kerberosConfig, servicePillar);
servicePillar.putAll(createUnboundEliminationPillar(stack.getDomainDnsResolver()));
addKerberosConfig(servicePillar, kerberosConfig);
servicePillar.putAll(hostAttributeDecorator.createHostAttributePillars(stack));
servicePillar.put("discovery", new SaltPillarProperties("/discovery/init.sls", singletonMap("platform", stack.cloudPlatform())));
String virtualGroupsEnvironmentCrn = environmentConfigProvider.getParentEnvironmentCrn(stack.getEnvironmentCrn());
boolean deployedInChildEnvironment = !virtualGroupsEnvironmentCrn.equals(stack.getEnvironmentCrn());
Map<String, ? extends Serializable> clusterProperties = Map.of("name", stack.getCluster().getName(), "deployedInChildEnvironment", deployedInChildEnvironment);
servicePillar.put("metadata", new SaltPillarProperties("/metadata/init.sls", singletonMap("cluster", clusterProperties)));
ClusterPreCreationApi connector = clusterApiConnectors.getConnector(cluster);
Map<String, List<String>> serviceLocations = getServiceLocations(cluster);
Optional<LdapView> ldapView = ldapConfigService.get(stack.getEnvironmentCrn(), stack.getName());
VirtualGroupRequest virtualGroupRequest = getVirtualGroupRequest(virtualGroupsEnvironmentCrn, ldapView);
servicePillar.putAll(createGatewayPillar(primaryGatewayConfig, cluster, stack, virtualGroupRequest, connector, kerberosConfig, serviceLocations, clouderaManagerRepo));
saveIdBrokerPillar(cluster, servicePillar);
postgresConfigService.decorateServicePillarWithPostgresIfNeeded(servicePillar, stack, cluster);
addClouderaManagerConfig(stack, cluster, servicePillar, clouderaManagerRepo, primaryGatewayConfig);
ldapView.ifPresent(ldap -> saveLdapPillar(ldap, servicePillar));
saveSssdAdPillar(servicePillar, kerberosConfig);
servicePillar.putAll(saveSssdIpaPillar(kerberosConfig, serviceLocations, stack.getEnvironmentCrn()));
Map<String, Map<String, String>> mountPathMap = stack.getInstanceGroups().stream().flatMap(group -> group.getInstanceMetaDataSet().stream().filter(instanceMetaData -> instanceMetaData.getDiscoveryFQDN() != null).collect(Collectors.toMap(InstanceMetaData::getDiscoveryFQDN, node -> Map.of("mount_path", getMountPath(group), "cloud_platform", stack.getCloudPlatform(), "temporary_storage", group.getTemplate().getTemporaryStorage().name()), (l, r) -> Map.of("mount_path", getMountPath(group), "cloud_platform", stack.getCloudPlatform(), "temporary_storage", group.getTemplate().getTemporaryStorage().name()))).entrySet().stream()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
servicePillar.put("startup", new SaltPillarProperties("/mount/startup.sls", singletonMap("mount", mountPathMap)));
proxyConfigProvider.decoratePillarWithProxyDataIfNeeded(servicePillar, cluster);
decoratePillarWithJdbcConnectors(cluster, servicePillar);
return new SaltConfig(servicePillar, grainsProperties);
}
use of com.sequenceiq.cloudbreak.dto.KerberosConfig in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method createSaltConfigWithGatewayPillarOnly.
private SaltConfig createSaltConfigWithGatewayPillarOnly(Stack stack, Cluster cluster, List<GrainProperties> grainsProperties) throws IOException, CloudbreakOrchestratorException {
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
String virtualGroupsEnvironmentCrn = environmentConfigProvider.getParentEnvironmentCrn(stack.getEnvironmentCrn());
ClusterPreCreationApi connector = clusterApiConnectors.getConnector(cluster);
Map<String, List<String>> serviceLocations = getServiceLocations(cluster);
LOGGER.debug("Getting LDAP config for Gateway pillar");
Optional<LdapView> ldapView = ldapConfigService.get(stack.getEnvironmentCrn(), stack.getName());
VirtualGroupRequest virtualGroupRequest = getVirtualGroupRequest(virtualGroupsEnvironmentCrn, ldapView);
LOGGER.debug("Getting kerberos config for Gateway pillar");
KerberosConfig kerberosConfig = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()).orElse(null);
ClouderaManagerRepo clouderaManagerRepo = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
LOGGER.debug("Creating gateway pillar");
Map<String, SaltPillarProperties> servicePillar = new HashMap<>(createGatewayPillar(primaryGatewayConfig, cluster, stack, virtualGroupRequest, connector, kerberosConfig, serviceLocations, clouderaManagerRepo));
return new SaltConfig(servicePillar, grainsProperties);
}
use of com.sequenceiq.cloudbreak.dto.KerberosConfig in project cloudbreak by hortonworks.
the class ClusterKerberosService method leaveDomains.
public void leaveDomains(Stack stack, Set<Node> nodes) throws CloudbreakException {
KerberosConfig kerberosConfig = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()).orElse(null);
if (kerberosDetailService.isAdJoinable(kerberosConfig) || kerberosDetailService.isIpaJoinable(kerberosConfig)) {
try {
GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
ExitCriteriaModel noExitModel = ClusterDeletionBasedExitCriteriaModel.nonCancellableModel();
if (kerberosDetailService.isAdJoinable(kerberosConfig)) {
hostOrchestrator.leaveDomain(gatewayConfig, nodes, "ad_member", "ad_leave", noExitModel);
} else if (kerberosDetailService.isIpaJoinable(kerberosConfig)) {
hostOrchestrator.leaveDomain(gatewayConfig, nodes, "ipa_member", "ipa_leave", noExitModel);
}
} catch (CloudbreakOrchestratorFailedException e) {
Set<Map.Entry<String, Collection<String>>> entries = e.getNodesWithErrors().asMap().entrySet();
String errors;
errors = entries.isEmpty() ? e.getMessage() : entries.stream().map(entry -> entry.getKey() + ": " + entry.getValue()).collect(Collectors.joining("\n"));
String message = "Leaving AD domain had some errors:\n" + errors;
throw new CloudbreakException(message, e);
}
}
}
use of com.sequenceiq.cloudbreak.dto.KerberosConfig in project cloudbreak by hortonworks.
the class KeytabConfigurationHandlerTest method shouldUpdateKeytabs.
@Test
public void shouldUpdateKeytabs() throws Exception {
KeytabConfigurationRequest keytabConfigurationRequest = new KeytabConfigurationRequest(STACK_ID);
Stack stack = aStack();
Optional<KerberosConfig> kerberosConfig = of(mock(KerberosConfig.class));
GatewayConfig gatewayConfig = mock(GatewayConfig.class);
when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
when(kerberosConfigService.get(ENVIRONMENT_CRN, STACK_NAME)).thenReturn(kerberosConfig);
when(environmentConfigProvider.isChildEnvironment(ENVIRONMENT_CRN)).thenReturn(true);
when(kerberosDetailService.keytabsShouldBeUpdated(CLOUD_PLATFORM, true, kerberosConfig)).thenReturn(true);
when(gatewayConfigService.getPrimaryGatewayConfig(stack)).thenReturn(gatewayConfig);
when(keytabProvider.getServiceKeytabResponse(stack, gatewayConfig)).thenReturn(mock(ServiceKeytabResponse.class));
when(secretService.getByResponse(any())).thenReturn(KEYTABS_IN_BASE64);
victim.accept(new Event<>(keytabConfigurationRequest));
verify(hostOrchestrator).uploadKeytabs(any(), any(), any());
verify(eventBus).notify(anyString(), any(Event.class));
}
use of com.sequenceiq.cloudbreak.dto.KerberosConfig in project cloudbreak by hortonworks.
the class KnoxGatewayConfigProviderTest method testGatewayWhitelistConfig.
@Test
public void testGatewayWhitelistConfig() {
TemplatePreparationObject noKerberosTPO = Builder.builder().withGeneralClusterConfigs(new GeneralClusterConfigs()).build();
assertEquals(config("gateway_dispatch_whitelist", "^*.*$"), underTest.getGatewayWhitelistConfig(noKerberosTPO));
KerberosConfig kerberosConfig = KerberosConfig.KerberosConfigBuilder.aKerberosConfig().withDomain("example.com").build();
TemplatePreparationObject kerberosNoAutoTlsTPO = Builder.builder().withGeneralClusterConfigs(new GeneralClusterConfigs()).withKerberosConfig(kerberosConfig).build();
assertEquals(config("gateway_dispatch_whitelist", "^/.*$;^https?://(.+.example.com):[0-9]+/?.*$"), underTest.getGatewayWhitelistConfig(kerberosNoAutoTlsTPO));
GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
generalClusterConfigs.setAutoTlsEnabled(true);
TemplatePreparationObject kerberosAutoTlsTPO = Builder.builder().withGeneralClusterConfigs(generalClusterConfigs).withKerberosConfig(kerberosConfig).build();
assertEquals(config("gateway_dispatch_whitelist", "^/.*$;^https://(.+.example.com):[0-9]+/?.*$"), underTest.getGatewayWhitelistConfig(kerberosAutoTlsTPO));
}
Aggregations