Examples of ExecResponse


Examples of org.jclouds.compute.domain.ExecResponse

        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 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());
        exchange.getOut().setBody(execResponse.getOutput());
    }
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

         Vm vm = Iterables.get(vapp.getChildren(), 0);
         String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript();
         checkApiOutput(apiOutput);

         ExecResponse vmTools = client.runScriptOnNode(node.getId(), PARSE_VMTOOLSD,
               wrapInInitScript(false).runAsRoot(false));
         checkApiOutput(new String(base64().decode(vmTools.getOutput().trim()), UTF_8));

         ExecResponse foo = client.runScriptOnNode(node.getId(), "cat /root/foo.txt", wrapInInitScript(false)
               .runAsRoot(false));
         checkCustomizationOccurred(foo);

      } finally {
         if (node != null)
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

   protected void doConnectViaSsh(Server server, LoginCredentials creds) throws IOException {
      SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class)
            .create(HostAndPort.fromParts(server.getVnc().getIp(), 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

Examples of org.jclouds.compute.domain.ExecResponse

                     exec("echo hello"),
                     overrideLoginCredentials(
                           LoginCredentials.builder().user(first.getCredentials().identity)
                                 .privateKey(keyPair.get("private")).build()).wrapInInitScript(false).runAsRoot(false));

         ExecResponse hello = getOnlyElement(responses.values());
         assertEquals(hello.getOutput().trim(), "hello");

      } finally {
         noSshContext.close();
         view.getComputeService().destroyNodesMatching(inGroup(group));
      }
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

      blockUntilWeCanSshIntoInstance(instance);
      SshClient ssh = sshFactory.create(HostAndPort.fromParts(instance.getIpAddress(), 22),
            LoginCredentials.builder().user("root").privateKey(keyPair.getKeyMaterial()).build());
      try {
         ssh.connect();
         ExecResponse uptime = ssh.exec("uptime");
         assert uptime.getOutput().indexOf("0 min") != -1 : "reboot didn't work: " + uptime;
      } finally {
         if (ssh != null)
            ssh.disconnect();
      }
   }
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

   private void doCheckKey(String address) {
      SshClient ssh = sshFactory.create(HostAndPort.fromParts(address, 22),
            LoginCredentials.builder().user("root").privateKey(keyPair.getKeyMaterial()).build());
      try {
         ssh.connect();
         ExecResponse hello = ssh.exec("echo hello");
         assertEquals(hello.getOutput().trim(), "hello");
      } finally {
         if (ssh != null)
            ssh.disconnect();
      }
   }
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

         ssh.put(script, Payloads.newStringPayload(mkEbsBoot));

         System.out.printf("%d: %s launching ebs script%n", System.currentTimeMillis(), instance.getId());
         ssh.exec("chmod 755 " + script);
         ssh.exec(script + " init");
         ExecResponse output = ssh.exec("sudo " + script + " start");
         System.out.println(output);
         output = ssh.exec(script + " status");

         assert !output.getOutput().trim().equals("") : output;
         Predicate<String> scriptTester = retry(new ScriptTester(ssh, SCRIPT_END), 600, 10, SECONDS);
         scriptTester.apply(script);
      } finally {
         if (ssh != null)
            ssh.disconnect();
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

   private void doCheckKey(String address) {
      SshClient ssh = sshFactory.create(HostAndPort.fromParts(address, 22),
            LoginCredentials.builder().user("ubuntu").privateKey(keyPair.getKeyMaterial()).build());
      try {
         ssh.connect();
         ExecResponse hello = ssh.exec("echo hello");
         assertEquals(hello.getOutput().trim(), "hello");
      } finally {
         if (ssh != null)
            ssh.disconnect();
      }
   }
View Full Code Here

Examples of org.jclouds.compute.domain.ExecResponse

      }

      @Override
      public boolean apply(String script) {
         System.out.printf("%d: %s testing status%n", System.currentTimeMillis(), script);
         ExecResponse output = ssh.exec(script + " status");
         if (output.getOutput().trim().equals("")) {
            output = ssh.exec(script + " tail");
            String stdout = output.getOutput().trim();
            if (stdout.contains(endMatches)) {
               return true;
            } else {
               output = ssh.exec(script + " tailerr");
               String stderr = output.getOutput().trim();
               throw new RuntimeException(String.format(
                     "script %s ended without token: stdout.log: [%s]; stderr.log: [%s]; ", script, stdout, stderr));
            }
         }
         return false;
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.