Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.ExecResponse


      if (expectedMd5 != null) {
         String filePath = isosDir + File.separator + fileName;
         ListenableFuture<ExecResponse> md5future = runScriptOnNodeFactory.submit(hostNode, new Md5(filePath),
               runAsRoot(false));

         ExecResponse responseMd5 = Futures.getUnchecked(md5future);
         assert responseMd5.getExitStatus() == 0 : hostNode.getId() + ": " + responseMd5;
         checkNotNull(responseMd5.getOutput(), "iso_md5 missing");
         String actualMd5 = responseMd5.getOutput().trim();
         checkState(actualMd5.equals(expectedMd5), "md5 of %s is %s but expected %s", filePath, actualMd5, expectedMd5);
      }
      return file.getAbsolutePath();
   }
View Full Code Here


            .add(kill()).build();
      StatementList statementList = new StatementList(statements);

      if (socketTester.apply(HostAndPort.fromParts(provider.getHost(), provider.getPort()))) {
         logger.debug(String.format("shutting down previously started vboxwewbsrv at %s", provider));
         ExecResponse execResponse = runScriptOnNodeFactory.create(hostNodeMetadata, statementList, runAsRoot(false))
               .init().call();
         if (execResponse.getExitStatus() != 0)
            throw new RuntimeException(String.format("Cannot shutdown a running vboxwebsrv at %s. ExecResponse: %s", provider, execResponse));
      }
   }
View Full Code Here

    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.getExitCode() != 0) {
        rc = response.getExitCode();
      }
      out.printf("%s%n", response.getOutput());
      err.printf("%s%n", response.getError());
    }
    return rc;
  }
View Full Code Here

      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

   protected void doConnectViaSsh(VirtualGuest guest, LoginCredentials creds) {
      SshClient ssh = sshFactory.create(HostAndPort.fromParts(guest.getPrimaryIpAddress(), 22), creds);
      try {
         ssh.connect();
         ExecResponse hello = ssh.exec("echo hello");
         assertEquals(hello.getOutput().trim(), "hello");
         System.err.println(ssh.exec("df -k").getOutput());
         System.err.println(ssh.exec("mount").getOutput());
         System.err.println(ssh.exec("uname -a").getOutput());
      } finally {
         if (ssh != null)
View Full Code Here

        LoginCredentials credentials = null;

        if (user != null) {
            credentials = LoginCredentials.builder().user(user).build();
        }
        ExecResponse execResponse = null;

        if (credentials == null) {
            execResponse = computeService.runScriptOnNode(nodeId, script);
        } else {
            execResponse = computeService.runScriptOnNode(nodeId, script, RunScriptOptions.Builder.overrideLoginCredentials(credentials).runAsRoot(false));
        }

        if (execResponse == null) {
            throw new CamelExchangeException("Failed to receive response for run script operation on node: " + nodeId + " using script: " + script, exchange);
        }

        exchange.setProperty(JcloudsConstants.RUN_SCRIPT_ERROR, execResponse.getError());
        exchange.setProperty(JcloudsConstants.RUN_SCRIPT_EXIT_CODE, execResponse.getExitStatus());
        exchange.getOut().setBody(execResponse.getOutput());
    }
View Full Code Here

      }
    }

    for (Future<ExecResponse> future : futures) {
      try {
        ExecResponse execResponse = future.get();
        if (execResponse.getExitCode() != 0) {
          LOG.error("Error running " + phaseName + " script: {}", execResponse);
        } else {
          LOG.info("Successfully executed {} script: {}", phaseName, execResponse);
        }
      } catch (ExecutionException e) {
View Full Code Here

      // 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 {
        exec = new ExecResponse("", "", 0);
      }

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

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

        Credentials credentials = null;

        if (user != null) {
            credentials = new Credentials(user, null);
        }
        ExecResponse execResponse = null;

        if (credentials == null) {
            execResponse = computeService.runScriptOnNode(nodeId, script);
        } else {
            execResponse = computeService.runScriptOnNode(nodeId, script, RunScriptOptions.Builder.overrideCredentialsWith(credentials).runAsRoot(false));
        }

        if (execResponse == null) {
            throw new CamelException("Failed to receive response for run script operation.");
        }

        exchange.setProperty(JcloudsConstants.RUN_SCRIPT_ERROR, execResponse.getError());
        exchange.setProperty(JcloudsConstants.RUN_SCRIPT_EXIT_CODE, execResponse.getExitCode());
        if (execResponse != null) {
            exchange.getOut().setBody(execResponse.getOutput());
        }
    }
View Full Code Here

               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

TOP

Related Classes of org.jclouds.compute.domain.ExecResponse

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.