use of com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel 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.RecipeModel in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method convert.
private List<RecipeModel> convert(Iterable<Recipe> recipes) {
List<RecipeModel> result = new ArrayList<>();
for (Recipe recipe : recipes) {
String decodedContent = new String(Base64.decodeBase64(recipe.getContent()));
RecipeModel recipeModel = new RecipeModel(recipe.getName(), recipe.getRecipeType(), decodedContent);
result.add(recipeModel);
}
return result;
}
use of com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method recipesEvent.
private void recipesEvent(Long stackId, Status status, Map<String, List<RecipeModel>> recipeMap) {
List<String> recipes = new ArrayList<>();
for (Entry<String, List<RecipeModel>> entry : recipeMap.entrySet()) {
Collection<String> recipeNamesPerHostgroup = new ArrayList<>(entry.getValue().size());
for (RecipeModel rm : entry.getValue()) {
// filter out default recipes
if (!DEFAULT_RECIPES.contains(rm.getName())) {
recipeNamesPerHostgroup.add(rm.getName());
}
}
if (!recipeNamesPerHostgroup.isEmpty()) {
String recipeNamesStr = Joiner.on(',').join(recipeNamesPerHostgroup);
recipes.add(String.format("%s:[%s]", entry.getKey(), recipeNamesStr));
}
}
if (!recipes.isEmpty()) {
Collections.sort(recipes);
String messageStr = Joiner.on(';').join(recipes);
cloudbreakEventService.fireCloudbreakEvent(stackId, status.name(), cloudbreakMessagesService.getMessage(Msg.UPLOAD_RECIPES.code(), Collections.singletonList(messageStr)));
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel in project cloudbreak by hortonworks.
the class SaltOrchestrator method uploadRecipes.
@Override
public void uploadRecipes(List<GatewayConfig> allGatewayConfigs, Map<String, List<RecipeModel>> recipes, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorFailedException {
GatewayConfig primaryGateway = allGatewayConfigs.stream().filter(GatewayConfig::isPrimary).findFirst().get();
Set<String> gatewayTargets = getGatewayPrivateIps(allGatewayConfigs);
try (SaltConnector sc = new SaltConnector(primaryGateway, restDebug)) {
OrchestratorBootstrap scriptPillarSave = new PillarSave(sc, gatewayTargets, recipes);
Callable<Boolean> saltPillarRunner = runner(scriptPillarSave, exitCriteria, exitModel);
Future<Boolean> saltPillarRunnerFuture = parallelOrchestratorComponentRunner.submit(saltPillarRunner);
saltPillarRunnerFuture.get();
for (List<RecipeModel> recipeList : recipes.values()) {
for (RecipeModel model : recipeList) {
uploadRecipe(sc, gatewayTargets, exitModel, model.getName(), model.getScript(), RecipeExecutionPhase.convert(model.getRecipeType()));
}
}
} catch (Exception e) {
LOGGER.error("Error occurred during recipe upload", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
Aggregations