Examples of ExecResponse


Examples of org.jclouds.compute.domain.ExecResponse

   }

   protected ServiceStats trackAvailabilityOfProcessOnNode(Statement process, String processName, NodeMetadata node) {
      ServiceStats stats = new ServiceStats();
      Stopwatch watch = new Stopwatch().start();
      ExecResponse exec = client.runScriptOnNode(node.getId(), process, runAsRoot(false).wrapInInitScript(false));
      stats.backgroundProcessMilliseconds = watch.elapsed(TimeUnit.MILLISECONDS);
      watch.reset().start();
     
      HostAndPort socket = null;
      try {
         socket = openSocketFinder.findOpenSocketOnNode(node, 8080, 600, TimeUnit.SECONDS);
      } catch (NoSuchElementException e) {
         throw new NoSuchElementException(format("%s%n%s%s", e.getMessage(), exec.getOutput(), exec.getError()));
      }

      stats.socketOpenMilliseconds = watch.elapsed(TimeUnit.MILLISECONDS);

      getAnonymousLogger().info(format("<< %s on node(%s)[%s] %s", processName, node.getId(), socket, stats));
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

   protected void doCheckJavaIsInstalledViaSsh(NodeMetadata node, String taskName) throws IOException {
      SshClient ssh = view.utils().sshForNode().apply(node);
      try {
         ssh.connect();
         ExecResponse hello = ssh.exec("echo hello");
         assertEquals(hello.getOutput().trim(), "hello");
         ExecResponse exec = ssh.exec("java -version");
         assert exec.getError().indexOf("OpenJDK") != -1 || exec.getOutput().indexOf("OpenJDK") != -1 : exec
               + "\n"
               + ssh.exec("cat /tmp/" + taskName + "/" + taskName + ".sh /tmp/" + taskName + "/stdout.log /tmp/"
                     + taskName + "/stderr.log");
      } finally {
         if (ssh != null)
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

      // jclouds to call status multiple times (5 by default) before
      // returning exitCode 1.
      if (delay.get() == null) {
        delay.set(new AtomicInteger(0));
      }
      ExecResponse exec;
      if (script.endsWith(" status")) {
        if (delay.get().get() >= callDelay) {
          exec = new ExecResponse("", "", 1);
        } else {
          exec = new ExecResponse("", "", 0);
        }
      } else if (script.endsWith(" exitstatus")) {
        // show return code is 0
        exec = new ExecResponse("0", "", 0);
      } else {
        exec = new ExecResponse("", "", 0);
      }

      LOG.info(toString() + " << " + exec);

      delay.get().getAndIncrement();
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

      Map<? extends NodeMetadata, ExecResponse> responseMap = controller.runScriptOnNodesMatching(
        spec,
        Predicates.<NodeMetadata>alwaysTrue(),
        exec("cat /tmp/bootstrap-start /tmp/bootstrap-end /tmp/configure-start")
      );
      ExecResponse response = Iterables.get(responseMap.values(), 0);
      LOG.info("Got response: {}", response);

      String[] parts = Strings.split(response.getOutput(), '\n');

      int bootstrapStart = parseInt(deleteWhitespace(parts[0]));
      int bootstrapEnd = parseInt(deleteWhitespace(parts[1]));
      int configureStart = parseInt(deleteWhitespace(parts[2]));
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

    for (Map.Entry<? extends NodeMetadata, ExecResponse> entry : responses.entrySet()) {
      out.printf("** Node %s: %s%n", entry.getKey().getId(),
        Iterables.concat(entry.getKey().getPrivateAddresses(),
          entry.getKey().getPublicAddresses()));

      ExecResponse response = entry.getValue();
      if (response.getExitStatus() != 0) {
        exitStatus = response.getExitStatus();
      }
      out.printf("%s%n", response.getOutput());
      err.printf("%s%n", response.getError());
    }
    return exitStatus;
  }
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

               logger.warn("<< " + message);
               backoffForAttempt(++i, message);
            }
            if (errorStatus == -1)
               throw new SshException(message);
            return new ExecResponse(outputString, errorString, errorStatus);
         } finally {
            clear();
         }
      }
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

               throw new RuntimeException("path " + path + " not stubbed");
            }

            public ExecResponse exec(String command) {
               if (command.equals("hostname")) {
                  return new ExecResponse(sshHost, "", 0);
               }
               throw new RuntimeException("command " + command + " not stubbed");
            }

            @Override
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

      assert contents.indexOf("root") >= 0 : "no root in " + contents;
   }

   public void testExecHostname() throws IOException, InterruptedException {
      SshClient client = setupClient();
      ExecResponse response = client.exec("hostname");
      assertEquals(response.getError(), "");
      assertEquals(response.getOutput().trim(), "localhost".equals(sshHost) ? InetAddress.getLocalHost().getHostName()
               : sshHost);
   }
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

               wrapInInitScript(false).runAsRoot(false).overrideLoginCredentials(good)).entrySet()) {
            checkResponseEqualsHostname(response.getValue(), response.getKey());
         }

         // test single-node execution
         ExecResponse response = client.runScriptOnNode(node.getId(), "hostname",
               wrapInInitScript(false).runAsRoot(false));
         checkResponseEqualsHostname(response, node);
         OperatingSystem os = node.getOperatingSystem();

         // test bad password
         tryBadPassword(group, good);

         runScriptWithCreds(group, os, good);

         checkNodes(nodes, group, "runScriptWithCreds");

         // test adding AdminAccess later changes the default boot user, in this
         // case to foo, with home dir /over/ridden/foo
         ListenableFuture<ExecResponse> future = client.submitScriptOnNode(node.getId(), AdminAccess.builder()
               .adminUsername("foo").adminHome("/over/ridden/foo").build(), nameTask("adminUpdate"));

         response = future.get(3, TimeUnit.MINUTES);

         assert response.getExitStatus() == 0 : node.getId() + ": " + response;

         node = client.getNodeMetadata(node.getId());
         // test that the node updated to the correct admin user!
         assertEquals(node.getCredentials().identity, "foo");
         assert node.getCredentials().credential != null : nodes;

         weCanCancelTasks(node);

         assert response.getExitStatus() == 0 : node.getId() + ": " + response;

         response = client.runScriptOnNode(node.getId(), "echo $USER", wrapInInitScript(false).runAsRoot(false));

         assert response.getOutput().trim().equals("foo") : node.getId() + ": " + response;

      } finally {
         client.destroyNodesMatching(inGroup(group));
      }
   }
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

   @Test(enabled = false)
   public void weCanCancelTasks(NodeMetadata node) throws InterruptedException, ExecutionException {
      ListenableFuture<ExecResponse> future = client.submitScriptOnNode(node.getId(), "sleep 300",
            nameTask("sleeper").runAsRoot(false));
      ExecResponse response = null;
      try {
         response = future.get(1, TimeUnit.MILLISECONDS);
         fail(node.getId() + ": " + response);
      } catch (TimeoutException e) {
         assert !future.isDone();
         response = client.runScriptOnNode(node.getId(), "/tmp/init-sleeper status",
               wrapInInitScript(false).runAsRoot(false));
         assert !response.getOutput().trim().equals("") : node.getId() + ": " + response;
         future.cancel(true);
         response = client.runScriptOnNode(node.getId(), "/tmp/init-sleeper status",
               wrapInInitScript(false).runAsRoot(false));
         assert response.getOutput().trim().equals("") : node.getId() + ": " + response;
         try {
            future.get();
            fail(future.toString());
         } catch (CancellationException e1) {
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.