Package org.jclouds.compute

Examples of org.jclouds.compute.ComputeService.runScriptOnNodesMatching()


          clusterSpec.getPrivateKey());
      try {
        LOG.info("Running configuration script");
        if (LOG.isDebugEnabled())
          LOG.debug("Running script:\n{}", statementBuilder.render(OsFamily.UNIX));
        computeService.runScriptOnNodesMatching(
            toNodeMetadataPredicate(clusterSpec, cluster, entry.getKey().getRoles()),
            statementBuilder,
            RunScriptOptions.Builder.overrideCredentialsWith(credentials));
        LOG.info("Configuration script run completed");
      } catch (RunScriptOnNodesException e) {
View Full Code Here


        @Override
        public Void call() throws Exception {
          LOG.info("Running script");
          if (LOG.isDebugEnabled())
            LOG.debug("Running script:\n{}", statementBuilder.render(OsFamily.UNIX));
          computeService.runScriptOnNodesMatching(
              Predicates.in(templateNodes),
              statementBuilder);
          LOG.info("Script run completed");
          return null;
        }
View Full Code Here

        LOG.info("Running configuration script on nodes: {}", nodesToApply.keySet());
        if (LOG.isDebugEnabled())
          LOG.debug("script:\n{}", statementBuilder.render(OsFamily.UNIX));
       
        computeService.runScriptOnNodesMatching(
            withIds(nodesToApply.keySet()),
            statementBuilder,
            RunScriptOptions.Builder.overrideCredentialsWith(credentials)
        );
       
View Full Code Here

        @Override
        public Void call() throws Exception {
          LOG.info("Running script");
          if (LOG.isDebugEnabled())
            LOG.debug("Running script:\n{}", statementBuilder.render(OsFamily.UNIX));
          computeService.runScriptOnNodesMatching(
              Predicates.in(templateNodes),
              statementBuilder);
          LOG.info("Script run completed");
          return null;
        }
View Full Code Here

    ComputeServiceContext computeServiceContext = getCompute().apply(spec);
    ComputeService computeService = computeServiceContext.getComputeService();
    Cluster cluster = getClusterStateStore(spec).load();

    RunScriptOptions options = RunScriptOptions.Builder.runAsRoot(false).wrapInInitScript(false);
    return computeService.runScriptOnNodesMatching(Predicates.<NodeMetadata>and(condition, runningIn(cluster)), statement, options);
  }

  private Predicate<NodeMetadata> runningIn(Cluster cluster) {
    final Set<String> instanceIds = new HashSet<String>(Collections2.transform(cluster.getInstances(), new Function<Instance, String>() {
      @Override
View Full Code Here

        if (useConfiguredPrivateKey(config)) {
            loginBuilder.privateKey(Files.toString(new File(config.getPrivateKeyFile()), Charset.defaultCharset()));
        }

        computeService.runScriptOnNodesMatching(runningInGroup(config.getTagPrefix() + id),
                Statements.exec(buildStartupScript(id, config)),
                RunScriptOptions.Builder.blockOnComplete(false).overrideLoginCredentials(loginBuilder.build()));
    }

    private boolean useConfiguredPrivateKey(JcloudsNodeLauncherConfig config) {
View Full Code Here

        template.getOptions().runAsRoot(m_runAsRoot);

        Set<? extends NodeMetadata> tag = computeService.createNodesInGroup(m_tagPrefix + id, 1, template);
        System.out.println("In case you need it, this is the key to ssh to " + id + ":\n"
                + tag.iterator().next().getCredentials().credential);
        computeService.runScriptOnNodesMatching(runningInGroup(m_tagPrefix + id),
                Statements.exec(buildStartupScript(id)),
                RunScriptOptions.Builder.blockOnComplete(false));
    }
   
    int[] mergePorts(int[] first, int[] last) {
View Full Code Here

         }

         Map<? extends NodeMetadata, ExecResponse> responseMap = null;

          if (getScript() != null) {
              responseMap = service.runScriptOnNodesMatching(getNodeFilter(),
                      getScript(), overrideLoginCredentials(credentials).runAsRoot(runAsRoot()));
          } else if (getStatement() != null) {
             responseMap = service.runScriptOnNodesMatching(getNodeFilter(),
                      getStatement(), overrideLoginCredentials(credentials).runAsRoot(runAsRoot()));
          }
View Full Code Here

          if (getScript() != null) {
              responseMap = service.runScriptOnNodesMatching(getNodeFilter(),
                      getScript(), overrideLoginCredentials(credentials).runAsRoot(runAsRoot()));
          } else if (getStatement() != null) {
             responseMap = service.runScriptOnNodesMatching(getNodeFilter(),
                      getStatement(), overrideLoginCredentials(credentials).runAsRoot(runAsRoot()));
          }

          for (Map.Entry<? extends NodeMetadata, ExecResponse> entry : responseMap.entrySet()) {
            ExecResponse response = entry.getValue();
View Full Code Here

            System.out.printf(">> running [%s] on group %s as %s%n", command, groupName, login.identity);

            // when you run commands, you can pass options to decide whether to
            // run it as root, supply or own credentials vs from cache, and wrap
            // in an init script vs directly invoke
            Map<? extends NodeMetadata, ExecResponse> responses = compute.runScriptOnNodesMatching(//
                  inGroup(groupName), // predicate used to select nodes
                  exec(command), // what you actually intend to run
                  overrideLoginCredentials(login) // use my local user &
                                                 // ssh key
                        .runAsRoot(false) // don't attempt to run as root (sudo)
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.