use of com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method redeployGatewayPillarOnly.
public void redeployGatewayPillarOnly(Stack stack, Cluster cluster) {
throwIfNull(stack, () -> new IllegalArgumentException("Stack should not be null"));
throwIfNull(cluster, () -> new IllegalArgumentException("Cluster should not be null"));
try {
Set<Node> allNodes = stackUtil.collectNodes(stack);
Set<Node> reachableNodes = stackUtil.collectReachableNodes(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
List<GrainProperties> grainsProperties = grainPropertiesService.createGrainProperties(gatewayConfigs, cluster, reachableNodes);
SaltConfig saltConfig = createSaltConfigWithGatewayPillarOnly(stack, cluster, grainsProperties);
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
LOGGER.debug("Calling orchestrator to upload gateway pillar");
hostOrchestrator.uploadGatewayPillar(gatewayConfigs, allNodes, exitCriteriaModel, saltConfig);
} catch (CloudbreakOrchestratorCancelledException e) {
LOGGER.debug("Orchestration cancelled during redeploying gateway pillar", e);
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException e) {
LOGGER.debug("Orchestration exception during redeploying gateway pillar", e);
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method redeployGatewayCertificate.
public void redeployGatewayCertificate(Stack stack, Cluster cluster) {
throwIfNull(stack, () -> new IllegalArgumentException("Stack should not be null"));
throwIfNull(cluster, () -> new IllegalArgumentException("Cluster should not be null"));
try {
Set<Node> allNodes = stackUtil.collectNodes(stack);
Set<Node> reachableNodes = stackUtil.collectReachableNodes(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
List<GrainProperties> grainsProperties = grainPropertiesService.createGrainProperties(gatewayConfigs, cluster, reachableNodes);
SaltConfig saltConfig = createSaltConfig(stack, cluster, grainsProperties);
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
hostOrchestrator.uploadGatewayPillar(gatewayConfigs, allNodes, exitCriteriaModel, saltConfig);
hostOrchestrator.runService(gatewayConfigs, reachableNodes, saltConfig, exitCriteriaModel);
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties 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.orchestrator.model.GrainProperties in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method updateClusterConfigs.
public void updateClusterConfigs(@Nonnull Stack stack, @Nonnull Cluster cluster) {
try {
Set<Node> allNodes = stackUtil.collectNodes(stack);
Set<Node> reachableNodes = stackUtil.collectReachableNodesByInstanceStates(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
List<GrainProperties> grainsProperties = grainPropertiesService.createGrainProperties(gatewayConfigs, cluster, reachableNodes);
SaltConfig saltConfig = createSaltConfig(stack, cluster, grainsProperties);
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
hostOrchestrator.initSaltConfig(stack, gatewayConfigs, allNodes, saltConfig, exitCriteriaModel);
hostOrchestrator.runService(gatewayConfigs, reachableNodes, saltConfig, exitCriteriaModel);
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties in project cloudbreak by hortonworks.
the class GrainPropertiesService method addKnoxRoleForHosts.
private GrainProperties addKnoxRoleForHosts(Cluster cluster, Set<Node> nodes) {
GrainProperties grainProperties = new GrainProperties();
Map<String, List<String>> knoxServiceLocations = filteredLocations(cluster, KnoxRoles.KNOX_GATEWAY, nodes);
knoxServiceLocations.getOrDefault(KnoxRoles.KNOX_GATEWAY, List.of()).forEach(nmn -> grainProperties.computeIfAbsent(nmn, s -> new HashMap<>()).put(ROLES, "knox"));
return grainProperties.getProperties().isEmpty() ? null : grainProperties;
}
Aggregations