use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class SaltOrchestrator method bootstrap.
@Override
public void bootstrap(List<GatewayConfig> allGatewayConfigs, Set<Node> targets, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorException {
LOGGER.info("Start SaltBootstrap on nodes: {}", targets);
GatewayConfig primaryGateway = getPrimaryGatewayConfig(allGatewayConfigs);
Set<String> gatewayTargets = getGatewayPrivateIps(allGatewayConfigs);
try (SaltConnector sc = new SaltConnector(primaryGateway, restDebug)) {
uploadSaltConfig(sc, gatewayTargets, exitModel);
uploadSignKey(sc, primaryGateway, gatewayTargets, targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet()), exitModel);
OrchestratorBootstrap saltBootstrap = new SaltBootstrap(sc, allGatewayConfigs, targets);
Callable<Boolean> saltBootstrapRunner = runner(saltBootstrap, exitCriteria, exitModel);
Future<Boolean> saltBootstrapRunnerFuture = parallelOrchestratorComponentRunner.submit(saltBootstrapRunner);
saltBootstrapRunnerFuture.get();
} catch (Exception e) {
LOGGER.error("Error occurred during the salt bootstrap", e);
throw new CloudbreakOrchestratorFailedException(e);
}
LOGGER.info("SaltBootstrap finished");
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class AmbariDecommissioner method removeHostsFromOrchestrator.
private PollingResult removeHostsFromOrchestrator(Stack stack, AmbariClient ambariClient, List<String> hostNames) throws CloudbreakException {
Orchestrator orchestrator = stack.getOrchestrator();
Map<String, Object> map = new HashMap<>(orchestrator.getAttributes().getMap());
OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(orchestrator.getType());
try {
if (orchestratorType.containerOrchestrator()) {
OrchestrationCredential credential = new OrchestrationCredential(orchestrator.getApiEndpoint(), map);
ContainerOrchestrator containerOrchestrator = containerOrchestratorResolver.get(orchestrator.getType());
Set<Container> containers = containerRepository.findContainersInCluster(stack.getCluster().getId());
List<ContainerInfo> containersToDelete = containers.stream().filter(input -> hostNames.contains(input.getHost()) && input.getImage().contains(AMBARI_AGENT.getName())).map(input -> new ContainerInfo(input.getContainerId(), input.getName(), input.getHost(), input.getImage())).collect(Collectors.toList());
containerOrchestrator.deleteContainer(containersToDelete, credential);
containerRepository.delete(containers);
return waitForHostsToLeave(stack, ambariClient, hostNames);
} else if (orchestratorType.hostOrchestrator()) {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
Map<String, String> privateIpsByFQDN = new HashMap<>();
stack.getInstanceMetaDataAsList().stream().filter(instanceMetaData -> hostNames.stream().anyMatch(hn -> hn.contains(instanceMetaData.getDiscoveryFQDN().split("\\.")[0]))).forEach(instanceMetaData -> privateIpsByFQDN.put(instanceMetaData.getDiscoveryFQDN(), instanceMetaData.getPrivateIp()));
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
hostOrchestrator.tearDown(allGatewayConfigs, privateIpsByFQDN);
}
} catch (CloudbreakOrchestratorException e) {
LOGGER.error("Failed to delete orchestrator components while decommissioning: ", e);
throw new CloudbreakException("Failed to delete orchestrator components while decommissioning: ", e);
}
return SUCCESS;
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method postAmbariStartRecipes.
public void postAmbariStartRecipes(Stack stack) throws CloudbreakException {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
try {
hostOrchestrator.postAmbariStartRecipes(gatewayConfig, collectNodes(stack), clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
} catch (CloudbreakOrchestratorFailedException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method uploadRecipes.
public void uploadRecipes(Stack stack, Collection<HostGroup> hostGroups) throws CloudbreakException {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
Map<String, List<RecipeModel>> recipeMap = hostGroups.stream().filter(hg -> !hg.getRecipes().isEmpty()).collect(Collectors.toMap(HostGroup::getName, h -> convert(h.getRecipes())));
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
recipesEvent(stack.getId(), stack.getStatus(), recipeMap);
try {
hostOrchestrator.uploadRecipes(allGatewayConfigs, recipeMap, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
} catch (CloudbreakOrchestratorFailedException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class SaltBootstrap method createBootstrap.
private SaltAction createBootstrap() {
SaltAction saltAction = new SaltAction(SaltActionType.RUN);
SaltAuth auth = new SaltAuth();
auth.setPassword(sc.getSaltPassword());
List<String> targetIps = targets.stream().map(Node::getPrivateIp).collect(Collectors.toList());
for (GatewayConfig gatewayConfig : allGatewayConfigs) {
String gatewayAddress = gatewayConfig.getPrivateAddress();
if (targetIps.contains(gatewayAddress)) {
Node saltMaster = targets.stream().filter(n -> n.getPrivateIp().equals(gatewayAddress)).findFirst().get();
SaltMaster master = new SaltMaster();
master.setAddress(gatewayAddress);
master.setAuth(auth);
master.setDomain(saltMaster.getDomain());
master.setHostName(saltMaster.getHostname());
// set due to compatibility reasons
saltAction.setServer(gatewayAddress);
saltAction.setMaster(master);
saltAction.addMinion(createMinion(saltMaster));
saltAction.addMaster(master);
}
}
for (Node minion : targets.stream().filter(node -> !getGatewayPrivateIps().contains(node.getPrivateIp())).collect(Collectors.toList())) {
saltAction.addMinion(createMinion(minion));
}
return saltAction;
}
Aggregations