Search in sources :

Example 1 with RecipeScript

use of com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript in project cloudbreak by hortonworks.

the class AbstractFileSystemConfiguratorTest method testGetScripts.

@Test
public void testGetScripts() {
    Credential credential = new Credential();
    credential.setId(0L);
    FileSystemConfiguration fsConfig = new FileSystemConfiguration();
    List<RecipeScript> actual = underTest.getScripts(credential, fsConfig);
    List<RecipeScript> expected = singletonList(new RecipeScript("echo 'newContent'", ExecutionType.ALL_NODES, RecipeType.POST_AMBARI_START));
    Assert.assertEquals(expected, actual);
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) FileSystemConfiguration(com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration) Test(org.junit.Test)

Example 2 with RecipeScript

use of com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript in project cloudbreak by hortonworks.

the class RecipeEngine method addHDFSRecipe.

private void addHDFSRecipe(Cluster cluster, String blueprintText, Iterable<HostGroup> hostGroups) {
    try {
        for (HostGroup hostGroup : hostGroups) {
            if (isComponentPresent(blueprintText, "NAMENODE", hostGroup)) {
                String script = FileReaderUtils.readFileFromClasspath("scripts/hdfs-home.sh").replaceAll("\\$USER", cluster.getUserName());
                RecipeScript recipeScript = new RecipeScript(script, RecipeType.POST_CLUSTER_INSTALL);
                Recipe recipe = recipeBuilder.buildRecipes("hdfs-home", Collections.singletonList(recipeScript)).get(0);
                hostGroup.addRecipe(recipe);
                break;
            }
        }
    } catch (IOException e) {
        LOGGER.warn("Cannot create HDFS home dir recipe", e);
    }
}
Also used : RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) Recipe(com.sequenceiq.cloudbreak.domain.Recipe) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) IOException(java.io.IOException)

Example 3 with RecipeScript

use of com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript in project cloudbreak by hortonworks.

the class RecipeEngine method addContainerExecutorScripts.

private void addContainerExecutorScripts(Stack stack, Iterable<HostGroup> hostGroups) {
    try {
        Cluster cluster = stack.getCluster();
        if (cluster != null && ExecutorType.CONTAINER.equals(cluster.getExecutorType())) {
            for (HostGroup hostGroup : hostGroups) {
                String script = FileReaderUtils.readFileFromClasspath("scripts/configure-container-executor.sh");
                RecipeScript recipeScript = new RecipeScript(script, RecipeType.POST_CLUSTER_INSTALL);
                Recipe recipe = recipeBuilder.buildRecipes("getConfigurationEntries-container-executor", Collections.singletonList(recipeScript)).get(0);
                hostGroup.addRecipe(recipe);
            }
        }
    } catch (IOException e) {
        LOGGER.warn("Cannot getConfigurationEntries container executor", e);
    }
}
Also used : RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) Recipe(com.sequenceiq.cloudbreak.domain.Recipe) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) IOException(java.io.IOException)

Example 4 with RecipeScript

use of com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript in project cloudbreak by hortonworks.

the class RecipeEngine method addSmartSenseRecipe.

private void addSmartSenseRecipe(Stack stack, Iterable<HostGroup> hostGroups) {
    try {
        Cluster cluster = stack.getCluster();
        String blueprintText = cluster.getBlueprint().getBlueprintText();
        if (smartsenseConfigurationLocator.smartsenseConfigurable(smartSenseSubscriptionService.getDefault())) {
            for (HostGroup hostGroup : hostGroups) {
                if (isComponentPresent(blueprintText, "HST_AGENT", hostGroup)) {
                    String script = FileReaderUtils.readFileFromClasspath("scripts/smartsense-capture-schedule.sh");
                    RecipeScript recipeScript = new RecipeScript(script, RecipeType.POST_CLUSTER_INSTALL);
                    Recipe recipe = recipeBuilder.buildRecipes("smartsense-capture-schedule", Collections.singletonList(recipeScript)).get(0);
                    hostGroup.addRecipe(recipe);
                    break;
                }
            }
        }
    } catch (IOException e) {
        LOGGER.warn("Cannot create SmartSense caputre schedule setter recipe", e);
    }
}
Also used : RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) Recipe(com.sequenceiq.cloudbreak.domain.Recipe) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) IOException(java.io.IOException)

Example 5 with RecipeScript

use of com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript in project cloudbreak by hortonworks.

the class AbstractFileSystemConfiguratorTest method testGetScriptsWhenNoReplace.

@Test
public void testGetScriptsWhenNoReplace() {
    Credential credential = new Credential();
    credential.setId(1L);
    FileSystemConfiguration fsConfig = new FileSystemConfiguration();
    List<RecipeScript> actual = underTest.getScripts(credential, fsConfig);
    List<RecipeScript> expected = singletonList(new RecipeScript("echo '$replace'", ExecutionType.ALL_NODES, RecipeType.POST_AMBARI_START));
    Assert.assertEquals(expected, actual);
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) FileSystemConfiguration(com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration) Test(org.junit.Test)

Aggregations

RecipeScript (com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript)8 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)5 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)4 IOException (java.io.IOException)4 FileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration)3 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 Credential (com.sequenceiq.cloudbreak.domain.Credential)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 FileSystemConfigurator (com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemConfigurator)1