Examples of ScriptBuilder


Examples of com.google.bitcoin.script.ScriptBuilder

    }

    public RuleList getBlocksToTest(boolean addSigExpensiveBlocks, boolean runLargeReorgs, File blockStorageFile) throws ScriptException, ProtocolException, IOException {
        final FileOutputStream outStream = blockStorageFile != null ? new FileOutputStream(blockStorageFile) : null;

        final Script OP_TRUE_SCRIPT = new ScriptBuilder().op(OP_TRUE).build();
        final Script OP_NOP_SCRIPT = new ScriptBuilder().op(OP_NOP).build();

        // TODO: Rename this variable.
        List<Rule> blocks = new LinkedList<Rule>() {
            @Override
            public boolean add(Rule element) {
View Full Code Here

Examples of com.google.bitcoin.script.ScriptBuilder

        TransactionInput input = new TransactionInput(params, t, new byte[]{}, prevOut.outpoint);
        input.setSequenceNumber(sequence);
        t.addInput(input);

        if (prevOut.scriptPubKey.getChunks().get(0).equalsOpCode(OP_TRUE)) {
            input.setScriptSig(new ScriptBuilder().op(OP_1).build());
        } else {
            // Sign input
            checkState(prevOut.scriptPubKey.isSentToRawPubKey());
            Sha256Hash hash = t.hashForSignature(0, prevOut.scriptPubKey, SigHash.ALL, false);
            input.setScriptSig(ScriptBuilder.createInputScript(
View Full Code Here

Examples of org.bitcoinj.script.ScriptBuilder

    private Transaction addRandomInput(Transaction tx) {
        tx = new Transaction(params, tx.bitcoinSerialize());
        byte[] rand = new byte[32];
        new SecureRandom().nextBytes(rand);
        tx.addInput(new TransactionInput(params, tx, new ScriptBuilder().data(rand).build().getProgram()));
        return tx;
    }
View Full Code Here

Examples of org.jclouds.scriptbuilder.ScriptBuilder

      assertEquals(keyPair.getKeyName(), keyName);
   }

   @Test(enabled = false, dependsOnMethods = { "testCreateKeyPair", "testCreateSecurityGroupIngressCidr" })
   public void testCreateRunningInstance() throws Exception {
      String script = new ScriptBuilder() // lamp install script
            .addStatement(exec("runurl run.alestic.com/apt/upgrade"))//
            .addStatement(exec("runurl run.alestic.com/install/lamp"))//
            .render(OsFamily.UNIX);

      RunningInstance instance = null;
View Full Code Here

Examples of org.jclouds.scriptbuilder.ScriptBuilder

  // Need to be able to specify base URL
  // Perhaps make these scripts parameterizable?
  // e.g. just java/install then base url is .../openjdk or .../sun or
  // .../apache or .../cloudera
  public static byte[] runUrls(String... urls) throws MalformedURLException {
    ScriptBuilder scriptBuilder = new ScriptBuilder().addStatement(
      exec("wget -qO/usr/bin/runurl run.alestic.com/runurl")).addStatement(
      exec("chmod 755 /usr/bin/runurl"));

    // Note that the runurl scripts should be checked in to whirr/scripts/
    String runUrlBase = System.getProperty("whirr.runurl.base", "http://whirr.s3.amazonaws.com/");
    for (String url : urls) {
      scriptBuilder.addStatement(exec("runurl " + new URL(new URL(runUrlBase), url)));
    }

    return scriptBuilder.build(org.jclouds.scriptbuilder.domain.OsFamily.UNIX)
      .getBytes();
  }
View Full Code Here

Examples of org.jclouds.scriptbuilder.ScriptBuilder

     return functions;
  }

  @Override
  public String render(OsFamily family) {
    ScriptBuilder scriptBuilder = new ScriptBuilder();
    for (Statement statement : statements) {
      scriptBuilder.addStatement(statement);
    }
    return scriptBuilder.build(family);
  }
View Full Code Here

Examples of org.jclouds.scriptbuilder.ScriptBuilder

   * @param urls The (possibly relative) URLs to build the runurls from.
   * @return
   * @throws MalformedURLException
   */
  public static String runUrls(String runUrlBase, String... urls) throws MalformedURLException {
    ScriptBuilder scriptBuilder = new ScriptBuilder().addStatement(
      exec("wget -qO/usr/bin/runurl run.alestic.com/runurl")).addStatement(
      exec("chmod 755 /usr/bin/runurl"));
    for (String url : urls) {
      String runUrl = new URL(new URL(runUrlBase), url).toExternalForm();
      scriptBuilder.addStatement(exec("runurl " + runUrl));
    }
    return scriptBuilder.build(OsFamily.UNIX);
  }
View Full Code Here

Examples of org.jclouds.scriptbuilder.ScriptBuilder

     return functions;
  }

  @Override
  public String render(OsFamily family) {
    ScriptBuilder scriptBuilder = new ScriptBuilder();
    for (Statement statement : statements) {
      scriptBuilder.addStatement(statement);
    }
    return scriptBuilder.render(family);
  }
View Full Code Here

Examples of org.jclouds.scriptbuilder.ScriptBuilder

       return functions;
    }

    @Override
    public String render(OsFamily family) {
      ScriptBuilder scriptBuilder = new ScriptBuilder();
      Map<String, String> metadataMap = Maps.newLinkedHashMap();
      metadataMap.putAll(
        ImmutableMap.of(
          "clusterName", clusterSpec.getClusterName(),
          "cloudProvider", clusterSpec.getProvider()
        )
      );
      if (instance != null) {
        metadataMap.putAll(
          ImmutableMap.of(
            "roles", Joiner.on(",").join(instance.getRoles()),
            "publicIp", instance.getPublicIp(),
            "privateIp", instance.getPrivateIp()
          )
        );
        if (!clusterSpec.isStub()) {
          try {
            metadataMap.putAll(
              ImmutableMap.of(
                "publicHostName", instance.getPublicHostName(),
                "privateHostName", instance.getPrivateHostName()
              )
            );
          } catch (IOException e) {
            LOG.warn("Could not resolve hostname for " + instance, e);
          }
        }
      }
      for (Iterator<?> it = clusterSpec.getConfiguration().getKeys("whirr.env"); it.hasNext(); ) {
        String key = (String)it.next();
        String value = clusterSpec.getConfiguration().getString(key);
        metadataMap.put(key.substring("whirr.env.".length()), value);
      }
      metadataMap.putAll(exports);
     
      // Write export statements out directly
      // Using InitBuilder would be a possible improvement
      String writeVariableExporters = Utils.writeVariableExporters(metadataMap, family);
      scriptBuilder.addStatement(exec(writeVariableExporters));
      for (Statement statement : statements) {
        scriptBuilder.addStatement(statement);
      }

      return scriptBuilder.render(family);
    }
View Full Code Here

Examples of org.jclouds.scriptbuilder.ScriptBuilder

   * @param forOs
   *            The operating system for which to render the script.
   * @return The script, rendered for a particular operating system.
   */
  public static String renderScript(String script, OsFamily forOs) {
    ScriptBuilder builder = new ScriptBuilder();
    Scanner scriptScanner = new Scanner(script);
    while (scriptScanner.hasNextLine()) {
      builder.addStatement(Statements.exec(scriptScanner.nextLine()));
    }
    scriptScanner.close();
    return builder.render(forOs);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.