use of com.sequenceiq.cloudbreak.cluster.api.ClusterPreCreationApi 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.cluster.api.ClusterPreCreationApi 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.cluster.api.ClusterPreCreationApi in project cloudbreak by hortonworks.
the class ClusterHostServiceRunnerTest method setupMocksForRunClusterServices.
private void setupMocksForRunClusterServices() {
when(umsClient.getAccountDetails(any(), any(), any())).thenReturn(UserManagementProto.Account.getDefaultInstance());
when(stackService.get(any())).thenReturn(stack);
when(stack.getCluster()).thenReturn(cluster);
when(stack.getTunnel()).thenReturn(Tunnel.DIRECT);
when(stack.getCloudPlatform()).thenReturn(CloudPlatform.AWS.name());
when(stack.getResourceCrn()).thenReturn(TEST_CLUSTER_CRN);
when(cluster.getName()).thenReturn("clustername");
when(cluster.getStack()).thenReturn(stack);
when(componentLocator.getComponentLocation(any(), any())).thenReturn(new HashMap<>());
when(exposedServiceCollector.getImpalaService()).thenReturn(mock(ExposedService.class));
when(environmentConfigProvider.getParentEnvironmentCrn(any())).thenReturn("crn:cdp:iam:us-west-1:accid:user:mockuser@cloudera.com");
ClouderaManagerRepo clouderaManagerRepo = mock(ClouderaManagerRepo.class);
when(clouderaManagerRepo.getVersion()).thenReturn("7.2.2");
GatewayConfig gatewayConfig = mock(GatewayConfig.class);
when(gatewayConfig.getPrivateAddress()).thenReturn("1.2.3.4");
when(gatewayConfig.getHostname()).thenReturn("hostname");
when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
when(clusterComponentConfigProvider.getClouderaManagerRepoDetails(any())).thenReturn(clouderaManagerRepo);
when(exposedServiceCollector.getRangerService()).thenReturn(mock(ExposedService.class));
ExposedService cmExposedService = mock(ExposedService.class);
when(cmExposedService.getServiceName()).thenReturn("CM");
when(exposedServiceCollector.getClouderaManagerService()).thenReturn(cmExposedService);
Template template = new Template();
template.setTemporaryStorage(TemporaryStorage.EPHEMERAL_VOLUMES);
Set<InstanceGroup> instanceGroups = new HashSet<>();
createInstanceGroup(template, instanceGroups, "fqdn1", null, "1.1.1.1", "1.1.1.2");
createInstanceGroup(template, instanceGroups, "fqdn2", null, "1.1.2.1", "1.1.2.2");
InstanceGroup gwIg = createInstanceGroup(template, instanceGroups, "gateway1", "gateway2", "1.1.3.1", "1.1.3.2");
lenient().when(stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()).thenReturn(Lists.newArrayList(gwIg.getAllInstanceMetaData()));
when(stack.getInstanceGroups()).thenReturn(instanceGroups);
RdsConfigWithoutCluster rdsConfigWithoutCluster = mock(RdsConfigWithoutCluster.class);
when(rdsConfigWithoutClusterService.findByClusterIdAndType(any(), eq(DatabaseType.CLOUDERA_MANAGER))).thenReturn(rdsConfigWithoutCluster);
when(rdsConfigWithoutCluster.getType()).thenReturn("asdf");
when(rdsConfigWithoutCluster.getConnectionURL()).thenReturn("jdbc:postgresql:subname://some-rds.1d3nt1f13r.eu-west-1.rds.amazonaws.com:5432/ranger");
when(rdsConfigWithoutCluster.getConnectionUserName()).thenReturn(new Secret("username"));
when(rdsConfigWithoutCluster.getConnectionPassword()).thenReturn(new Secret("password"));
when(loadBalancerSANProvider.getLoadBalancerSAN(stack)).thenReturn(Optional.empty());
ClusterPreCreationApi clusterPreCreationApi = mock(ClusterPreCreationApi.class);
when(clusterApiConnectors.getConnector(cluster)).thenReturn(clusterPreCreationApi);
ServiceLocationMap serviceLocationMap = new ServiceLocationMap();
serviceLocationMap.add(new ServiceLocation("serv", "paath"));
when(clusterPreCreationApi.getServiceLocations()).thenReturn(serviceLocationMap);
ReflectionTestUtils.setField(underTest, "cmHeartbeatInterval", "1");
ReflectionTestUtils.setField(underTest, "cmMissedHeartbeatInterval", "1");
}
Aggregations