Package org.jclouds.ssh

Examples of org.jclouds.ssh.SshClient.exec()


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


   @Test
   public void testExecInvalidCommand() throws IOException {
      SshClient client = setupClient();
      try {
         ExecResponse response = client.exec("thisCommandDoesNotExist");
         assertNotEquals(response.getExitStatus(), 0);
         assertTrue(response.getOutput().contains("not found") || response.getError().contains("not found"),
               "stdout="+response.getOutput()+"; stderr="+response.getError());
      } finally {
         client.disconnect();
View Full Code Here

   public void testExecHostnameRepeatedlyWithSameSessions() throws Exception {
      final SshClient client = setupClient();
     
      try {
         for (int i = 0; i < 100; i++) {
            ExecResponse response = client.exec("hostname");
            assertEquals(response.getError(), "");
            assertEquals(response.getOutput().trim(), "localhost".equals(sshHost) ? InetAddress.getLocalHost().getHostName()
                     : sshHost);
            //System.out.println("completed (sequentially) "+i);
         }
View Full Code Here

      try {
         for (int i = 0; i < 100; i++) {
            futures.add(userExecutor.submit(new Callable<ExecResponse>() {
               @Override
               public ExecResponse call() {
                  ExecResponse response = client.exec("hostname");
                  //System.out.println("completed (concurrently) "+count.incrementAndGet());
                  return response;
                 
               }
            }));
View Full Code Here

      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

         System.out.printf("%d: %s writing ebs script%n", System.currentTimeMillis(), instance.getId());
         String script = "/tmp/mkebsboot-init.sh";
         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");
View Full Code Here

         String script = "/tmp/mkebsboot-init.sh";
         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;
View Full Code Here

         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);
View Full Code Here

         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 {
View Full Code Here

   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

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.