Package org.jclouds.scriptbuilder.domain

Examples of org.jclouds.scriptbuilder.domain.Statement


   public String render(OsFamily family) {
      if (family == OsFamily.WINDOWS) {
         throw new UnsupportedOperationException("windows not yet implemented");
      }

      Statement statement = version.isPresent() ? exec(String.format("gem install chef -v '%s' --no-rdoc --no-ri",
            version.get())) : exec("gem install chef --no-rdoc --no-ri");

      return statement.render(family);
   }
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");
    if (LOG.isDebugEnabled())
      LOG.debug("Running script:\n{}", statementBuilder.render(OsFamily.UNIX));

    Statement runScript = addUserAndAuthorizeSudo(
        clusterSpec.getClusterUser(),
        clusterSpec.getPublicKey(),
        clusterSpec.getPrivateKey(),
        statementBuilder);
View Full Code Here

   public void testPublicAndRunScriptKeyDoesNotGenerateAuthorizePublicKeyStatementIfRunScriptPresent() {
      Map<String, String> keys = SshKeys.generate();
      TemplateOptions options = TemplateOptions.Builder.authorizePublicKey(keys.get("public")).runScript("uptime");

      TemplateOptionsToStatementWithoutPublicKey function = new TemplateOptionsToStatementWithoutPublicKey();
      Statement statement = function.apply(options);

      assertEquals(statement.render(OsFamily.UNIX), "uptime\n");
   }
View Full Code Here

      Map<String, String> keys = SshKeys.generate();
      TemplateOptions options = TemplateOptions.Builder.authorizePublicKey(keys.get("public"))
            .installPrivateKey(keys.get("private")).runScript("uptime");

      TemplateOptionsToStatementWithoutPublicKey function = new TemplateOptionsToStatementWithoutPublicKey();
      Statement statement = function.apply(options);

      assertTrue(statement instanceof StatementList);
      StatementList statements = (StatementList) statement;

      assertEquals(statements.size(), 2);
View Full Code Here

   }

   @Override
   public List<BridgedIf> apply(NodeMetadata host) {
      // Bridged Network
      Statement command = Statements.exec("VBoxManage list bridgedifs");
      String bridgedIfBlocks = runScriptOnNodeFactory.create(host, command, runAsRoot(false).wrapInInitScript(false))
               .init().call().getOutput();

      List<BridgedIf> bridgedInterfaces = retrieveBridgedInterfaceNames(bridgedIfBlocks);
      checkNotNull(bridgedInterfaces);
View Full Code Here

    TemplateBuilderStrategy strategy
  ) throws MalformedURLException {

    LOG.info("Configuring template");

    Statement runScript = addUserAndAuthorizeSudo(
        clusterSpec.getClusterUser(),
        clusterSpec.getPublicKey(),
        clusterSpec.getPrivateKey(),
        statementBuilder.build(clusterSpec));

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

    TemplateBuilder templateBuilder = computeService.templateBuilder()
      .options(runScript(runScript));
    strategy.configureTemplateBuilder(clusterSpec, templateBuilder);
View Full Code Here

  @Test
  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, "Java(TM) SE Runtime Environment");
View Full Code Here

      } catch (Exception e) {
         throw propagate(e);
      }

      String chefConfigDir = "{root}etc{fs}chef";
      Statement createChefConfigDir = exec("{md} " + chefConfigDir);
      Statement createClientRb = appendFile(chefConfigDir + "{fs}client.rb", ImmutableList.of("require 'rubygems'",
            "require 'ohai'", "o = Ohai::System.new", "o.all_plugins",
            String.format("node_name \"%s-\" + o[:ipaddress]", group), "log_level :info", "log_location STDOUT",
            String.format("validation_client_name \"%s\"", validatorClientName),
            String.format("chef_server_url \"%s\"", endpoint.get())));

      Statement createValidationPem = appendFile(chefConfigDir + "{fs}validation.pem",
            Splitter.on('\n').split(Pems.pem(validatorKey)));

      String chefBootFile = chefConfigDir + "{fs}first-boot.json";

      Statement createFirstBoot = appendFile(chefBootFile, Collections.singleton(json.toJson(bootstrapConfig)));

      Statement runChef = exec("chef-client -j " + chefBootFile);

      return newStatementList(installChefGems, createChefConfigDir, createClientRb, createValidationPem,
            createFirstBoot, runChef);
   }
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.