use of com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method runAmbariServices.
@Transactional
public void runAmbariServices(Stack stack, Cluster cluster) throws CloudbreakException {
try {
Set<Node> nodes = collectNodes(stack);
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
SaltConfig saltConfig = createSaltConfig(stack, cluster, primaryGatewayConfig, gatewayConfigs);
hostOrchestrator.runService(gatewayConfigs, nodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig in project cloudbreak by hortonworks.
the class AmbariClusterUpgradeService method upgradeCluster.
public void upgradeCluster(Long stackId) throws CloudbreakOrchestratorException {
Stack stack = stackRepository.findOneWithLists(stackId);
Cluster cluster = stack.getCluster();
try {
OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stack.getOrchestrator().getType());
if (orchestratorType.hostOrchestrator()) {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, cluster.getGateway().getEnableGateway());
Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
AmbariRepo ambariRepo = componentConfigProvider.getAmbariRepo(cluster.getId());
Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", ambariSecurityConfigProvider.getAmbariUserName(cluster));
credentials.put("password", ambariSecurityConfigProvider.getAmbariPassword(cluster));
servicePillar.put("ambari-credentials", new SaltPillarProperties("/ambari/credentials.sls", singletonMap("ambari", credentials)));
if (ambariRepo != null) {
servicePillar.put("ambari-repo", new SaltPillarProperties("/ambari/repo.sls", singletonMap("ambari", singletonMap("repo", ambariRepo))));
}
SaltConfig pillar = new SaltConfig(servicePillar);
hostOrchestrator.upgradeAmbari(gatewayConfig, gatewayFQDN, stackUtil.collectNodes(stack), pillar, exitCriteriaModel);
} else {
throw new UnsupportedOperationException("Ambari upgrade works only with host orchestrator");
}
} catch (CloudbreakException e) {
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method createSaltConfig.
private SaltConfig createSaltConfig(Stack stack, Cluster cluster, GatewayConfig primaryGatewayConfig, Iterable<GatewayConfig> gatewayConfigs) throws IOException, CloudbreakOrchestratorException {
Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
saveDatalakeNameservers(stack, servicePillar);
saveSharedRangerService(stack, servicePillar);
if (cluster.isSecure() && kerberosDetailService.isAmbariManagedKerberosPackages(cluster.getKerberosConfig())) {
Map<String, String> kerberosPillarConf = new HashMap<>();
KerberosConfig kerberosConfig = cluster.getKerberosConfig();
putIfNotNull(kerberosPillarConf, kerberosConfig.getMasterKey(), "masterKey");
putIfNotNull(kerberosPillarConf, kerberosConfig.getAdmin(), "user");
putIfNotNull(kerberosPillarConf, kerberosConfig.getPassword(), "password");
if (StringUtils.isEmpty(kerberosConfig.getDescriptor())) {
putIfNotNull(kerberosPillarConf, kerberosConfig.getUrl(), "url");
putIfNotNull(kerberosPillarConf, kerberosConfig.getAdminUrl(), "adminUrl");
putIfNotNull(kerberosPillarConf, kerberosConfig.getRealm(), "realm");
} else {
Map<String, Object> properties = kerberosDetailService.getKerberosEnvProperties(kerberosConfig);
putIfNotNull(kerberosPillarConf, properties.get("kdc_hosts"), "url");
putIfNotNull(kerberosPillarConf, properties.get("admin_server_host"), "adminUrl");
putIfNotNull(kerberosPillarConf, properties.get("realm"), "realm");
}
putIfNotNull(kerberosPillarConf, cluster.getUserName(), "clusterUser");
putIfNotNull(kerberosPillarConf, cluster.getPassword(), "clusterPassword");
servicePillar.put("kerberos", new SaltPillarProperties("/kerberos/init.sls", singletonMap("kerberos", kerberosPillarConf)));
}
servicePillar.put("discovery", new SaltPillarProperties("/discovery/init.sls", singletonMap("platform", stack.cloudPlatform())));
servicePillar.put("metadata", new SaltPillarProperties("/metadata/init.sls", singletonMap("cluster", singletonMap("name", stack.getCluster().getName()))));
saveGatewayPillar(primaryGatewayConfig, cluster, servicePillar);
AmbariRepo ambariRepo = clusterComponentConfigProvider.getAmbariRepo(cluster.getId());
if (ambariRepo != null) {
servicePillar.put("ambari-repo", new SaltPillarProperties("/ambari/repo.sls", singletonMap("ambari", singletonMap("repo", ambariRepo))));
}
servicePillar.put("ambari-gpl-repo", new SaltPillarProperties("/ambari/gpl.sls", singletonMap("ambari", singletonMap("gpl", singletonMap("enabled", clusterComponentConfigProvider.getHDPRepo(cluster.getId()).isEnableGplRepo())))));
decoratePillarWithAmbariDatabase(cluster, servicePillar);
saveLdapPillar(cluster.getLdapConfig(), servicePillar);
saveDockerPillar(cluster.getExecutorType(), servicePillar);
saveHDPPillar(cluster.getId(), servicePillar);
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", ambariSecurityConfigProvider.getAmbariUserName(stack.getCluster()));
credentials.put("password", ambariSecurityConfigProvider.getAmbariPassword(stack.getCluster()));
credentials.put("securityMasterKey", ambariSecurityConfigProvider.getAmbariSecurityMasterKey(cluster));
servicePillar.put("ambari-credentials", new SaltPillarProperties("/ambari/credentials.sls", singletonMap("ambari", credentials)));
if (smartSenseCredentialConfigService.areCredentialsSpecified()) {
Map<String, Object> smartSenseCredentials = smartSenseCredentialConfigService.getCredentials();
servicePillar.put("smartsense-credentials", new SaltPillarProperties("/smartsense/credentials.sls", smartSenseCredentials));
}
postgresConfigService.decorateServicePillarWithPostgresIfNeeded(servicePillar, stack, cluster);
proxyConfigProvider.decoratePillarWithProxyDataIfNeeded(servicePillar, cluster);
return new SaltConfig(servicePillar, createGrainProperties(gatewayConfigs));
}
use of com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method addAmbariServices.
@Transactional
public Map<String, String> addAmbariServices(Long stackId, String hostGroupName, Integer scalingAdjustment) throws CloudbreakException {
Map<String, String> candidates;
try {
Stack stack = stackRepository.findOneWithLists(stackId);
Cluster cluster = stack.getCluster();
candidates = collectUpscaleCandidates(cluster.getId(), hostGroupName, scalingAdjustment);
Set<Node> allNodes = collectNodes(stack);
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
SaltConfig saltConfig = createSaltConfig(stack, cluster, gatewayConfigService.getPrimaryGatewayConfig(stack), gatewayConfigs);
hostOrchestrator.runService(gatewayConfigs, allNodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakException(e);
}
return candidates;
}
use of com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig in project cloudbreak by hortonworks.
the class SaltOrchestratorTest method runServiceTest.
@Test
public void runServiceTest() throws Exception {
whenNew(SaltBootstrap.class).withAnyArguments().thenReturn(mock(SaltBootstrap.class));
whenNew(OrchestratorBootstrapRunner.class).withAnyArguments().thenReturn(mock(OrchestratorBootstrapRunner.class));
PillarSave pillarSave = mock(PillarSave.class);
whenNew(PillarSave.class).withAnyArguments().thenReturn(pillarSave);
GrainAddRunner addRemoveGrainRunner = mock(GrainAddRunner.class);
whenNew(GrainAddRunner.class).withAnyArguments().thenReturn(addRemoveGrainRunner);
SaltCommandTracker roleCheckerSaltCommandTracker = mock(SaltCommandTracker.class);
whenNew(SaltCommandTracker.class).withArguments(eq(saltConnector), eq(addRemoveGrainRunner)).thenReturn(roleCheckerSaltCommandTracker);
SyncGrainsRunner syncGrainsRunner = mock(SyncGrainsRunner.class);
whenNew(SyncGrainsRunner.class).withAnyArguments().thenReturn(syncGrainsRunner);
SaltCommandTracker syncGrainsCheckerSaltCommandTracker = mock(SaltCommandTracker.class);
whenNew(SaltCommandTracker.class).withArguments(eq(saltConnector), eq(syncGrainsRunner)).thenReturn(syncGrainsCheckerSaltCommandTracker);
HighStateRunner highStateRunner = mock(HighStateRunner.class);
whenNew(HighStateRunner.class).withAnyArguments().thenReturn(highStateRunner);
SaltJobIdTracker saltJobIdTracker = mock(SaltJobIdTracker.class);
whenNew(SaltJobIdTracker.class).withAnyArguments().thenReturn(saltJobIdTracker);
saltOrchestrator.init(parallelOrchestratorComponentRunner, exitCriteria);
SaltConfig saltConfig = new SaltConfig();
saltOrchestrator.runService(Collections.singletonList(gatewayConfig), targets, saltConfig, exitCriteriaModel);
// verify pillar save
verifyNew(OrchestratorBootstrapRunner.class, times(1)).withArguments(eq(pillarSave), eq(exitCriteria), eq(exitCriteriaModel), any(), anyInt(), anyInt());
// verify ambari server role
verifyNew(GrainAddRunner.class, times(1)).withArguments(eq(Sets.newHashSet(gatewayConfig.getPrivateAddress())), eq(targets), eq("ambari_server_install"));
// verify ambari server role
verifyNew(GrainAddRunner.class, times(1)).withArguments(eq(Sets.newHashSet(gatewayConfig.getPrivateAddress())), eq(targets), eq("ambari_server"));
// verify ambari agent role
Set<String> allNodes = targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
verifyNew(GrainAddRunner.class, times(1)).withArguments(eq(allNodes), eq(targets), eq("ambari_agent_install"));
// verify ambari agent role
allNodes = targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
verifyNew(GrainAddRunner.class, times(1)).withArguments(eq(allNodes), eq(targets), eq("ambari_agent"));
// verify two role command (amabari server, ambari agent)
verifyNew(SaltCommandTracker.class, times(4)).withArguments(eq(saltConnector), eq(addRemoveGrainRunner));
// verify two OrchestratorBootstrapRunner call with rolechecker command tracker
verifyNew(OrchestratorBootstrapRunner.class, times(4)).withArguments(eq(roleCheckerSaltCommandTracker), eq(exitCriteria), eq(exitCriteriaModel), any(), anyInt(), anyInt());
// verify syncgrains command
verifyNew(SyncGrainsRunner.class, times(1)).withArguments(eq(allNodes), eq(targets));
verifyNew(SaltCommandTracker.class, times(1)).withArguments(eq(saltConnector), eq(syncGrainsRunner));
verifyNew(OrchestratorBootstrapRunner.class, times(1)).withArguments(eq(syncGrainsCheckerSaltCommandTracker), eq(exitCriteria), eq(exitCriteriaModel), any(), anyInt(), anyInt());
// verify run new service
verifyNew(HighStateRunner.class, atLeastOnce()).withArguments(eq(allNodes), eq(targets));
verifyNew(SaltJobIdTracker.class, atLeastOnce()).withArguments(eq(saltConnector), eq(highStateRunner), eq(true));
}
Aggregations