Package org.jclouds.scriptbuilder.domain

Examples of org.jclouds.scriptbuilder.domain.Statement


      // we want everything as defaults except ram
      Template defaultTemplate = compute.templateBuilder().build();
      Template minecraft = compute.templateBuilder().fromTemplate(defaultTemplate).minRam(minRam).build();
     
      // setup the template to customize the node with jdk, etc. also opening ports.
      Statement bootstrap = newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK());
      minecraft.getOptions().inboundPorts(22, port).userMetadata(userMetadata).runScript(bootstrap);
     
      // example of using a cloud-specific hook
      if (minecraft.getOptions() instanceof AWSEC2TemplateOptions)
         minecraft.getOptions().as(AWSEC2TemplateOptions.class).enableMonitoring();
View Full Code Here


               templateBuilder.minRam(Integer.parseInt(minRam));
           
           
            // note this will create a user with the same name as you on the
            // node. ex. you can connect via ssh publicip
            Statement bootInstructions = AdminAccess.standard();

            // to run commands as root, we use the runScript option in the template.
            if(provider.equalsIgnoreCase("virtualbox"))
               templateBuilder.options(overrideLoginUser(loginUser).runScript(bootInstructions));
            else
View Full Code Here

                  templateBuilder.minRam(Integer.parseInt(minRam));
               }

               // note this will create a user with the same name as you on the
               // node. ex. you can connect via ssh publicip
               Statement bootInstructions = AdminAccess.standard();

               // to run commands as root, we use the runScript option in the
               // template.
               templateBuilder.options(runScript(bootInstructions));

               NodeMetadata node = getOnlyElement(compute.createNodesInGroup(groupName, 1, templateBuilder.build()));
               System.out.printf("<< node %s: %s%n", node.getId(),
                     concat(node.getPrivateAddresses(), node.getPublicAddresses()));

            case SOLO:
               System.out.printf(">> installing [%s] on group %s as %s%n", recipes, groupName, login.identity);

               Iterable<String> recipeList = Splitter.on(',').split(recipes);
               ImmutableList.Builder<Statement> bootstrapBuilder = ImmutableList.builder();
               bootstrapBuilder.add(new InstallGit());

               // Clone community cookbooks into the node
               for (String recipe : recipeList) {
                  bootstrapBuilder.add(CloneGitRepo.builder()
                        .repository("git://github.com/opscode-cookbooks/" + recipe + ".git")
                        .directory("/var/chef/cookbooks/" + recipe) //
                        .build());
               }

               // Configure Chef Solo to bootstrap the selected recipes
               bootstrapBuilder.add(InstallRuby.builder().build());
               bootstrapBuilder.add(InstallRubyGems.builder().build());
               bootstrapBuilder.add(ChefSolo.builder() //
                     .cookbookPath("/var/chef/cookbooks") //
                     .runlist(RunList.builder().recipes(recipeList).build()) //
                     .build());

               // Build the statement that will perform all the operations above
               StatementList bootstrap = new StatementList(bootstrapBuilder.build());

               // Run the script in the nodes of the group
               runScriptOnGroup(compute, login, groupName, bootstrap);
               break;
            case CHEF:
               // Create the connection to the Chef server
               ChefService chef = initChefService(System.getProperty("chef.client"),
                     System.getProperty("chef.validator"));

               // Build the runlist for the deployed nodes
               System.out.println("Configuring node runlist in the Chef server...");
               List<String> runlist = new RunListBuilder().addRecipes(recipes.split(",")).build();
               chef.updateRunListForGroup(runlist, groupName);
               Statement chefServerBootstrap = chef.createBootstrapScriptForGroup(groupName);

               // Run the script in the nodes of the group
               System.out.printf(">> installing [%s] on group %s as %s%n", recipes, groupName, login.identity);
               runScriptOnGroup(compute, login, groupName, chefServerBootstrap);
               break;
View Full Code Here

  @Test(timeout = TestConstants.ITEST_TIMEOUT)
  public void testRecipesWereRanInServiceBootstrap() throws Exception {

    // and shoudl be installed by the main handlers
    Statement testAnt = Statements.exec("ant -version");

    Map<? extends NodeMetadata, ExecResponse> responses = controller
        .runScriptOnNodesMatching(clusterSpec, allNodes, testAnt);

    printResponses(testAnt, responses);

    assertResponsesContain(responses, testAnt, "Apache Ant");

    Statement testMaven = Statements.exec("mvn --version");

    responses = controller.runScriptOnNodesMatching(clusterSpec, allNodes,
        testMaven);

    printResponses(testMaven, responses);
View Full Code Here

    Map<? extends NodeMetadata, ExecResponse> responses = runRecipe(java);

    printResponses(java, responses);

    Statement stmt = Statements.exec("java -version");

    responses = controller
        .runScriptOnNodesMatching(clusterSpec, allNodes, stmt);

    assertResponsesContain(responses, stmt, "Runtime Environment");
View Full Code Here

   * {@link ClusterActionEvent}.
   */
  public static void addRunUrl(ClusterActionEvent event, String runUrl,
                               String... args)
    throws IOException {
    Statement statement = new RunUrlStatement(
                                              event.getClusterSpec().getRunUrlBase(), runUrl, args);
    addStatement(event, statement);
  }
View Full Code Here

    LOG.info("Configuring template for {}", name);

    statementBuilder.name(name);
    ensureUserExistsAndAuthorizeSudo(statementBuilder, clusterSpec.getClusterUser(),
        clusterSpec.getPublicKey(), clusterSpec.getPrivateKey());
    Statement bootstrap = statementBuilder.build(clusterSpec);

    if (LOG.isDebugEnabled()) {
      LOG.debug("Running script {}:\n{}", name, bootstrap.render(OsFamily.UNIX));
    }

    TemplateBuilder templateBuilder = computeService.templateBuilder().from(
        instanceTemplate.getTemplate() != null ? instanceTemplate.getTemplate() :
        clusterSpec.getTemplate());
View Full Code Here

public class RunScriptOnNodeAsInitScriptUsingSshTest {
   EventBus eventBus = new EventBus();

   @Test(expectedExceptions = IllegalStateException.class)
   public void testWithoutInitThrowsIllegalStateException() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
               LoginCredentials.builder().user("tester").password("notalot").build()).build();

      SshClient sshClient = createMock(SshClient.class);
View Full Code Here

      testMe.call();
   }

   public void testDefault() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
            LoginCredentials.builder().user("tester").password("notalot").build()).build();

      SshClient sshClient = createMock(SshClient.class);
View Full Code Here

      verify(sshClient);
   }


   public void testWithSudoPassword() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
            LoginCredentials.builder().user("tester").password("notalot").authenticateSudo(true).build()).build();

      SshClient sshClient = createMock(SshClient.class);
View Full Code Here

TOP

Related Classes of org.jclouds.scriptbuilder.domain.Statement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.