Package com.trendmicro.mist.client

Examples of com.trendmicro.mist.client.MistClient$Session


  }

  private Session startProcess(List<String> commands) throws IOException {
    String command = ToolBox.createCommandString(commands);
    SSHDataHandler dataHandler = getHandler();
    Session sess = dataHandler.createSession();
    if (sess == null)
      throw new IOException("Session corrupt");
    sess.execCommand(command);
    return sess;
  }
View Full Code Here


  public void startGromacsProgram(List<String> commands,
      OutputStream outStream, boolean interactive, OutputStream helperStream) throws IOException {
    SSHDataHandler dataHandler = getHandler();
    if (commands.get(0).equals(GromacsConstants.MDRUN)
        && remoteProject.isUseMPILib()) {
      Session mpiSess = dataHandler.createSession();
      mpiSess.execCommand(remoteProject.getMpiLib());
      outputSession(mpiSess);
      // outputStdout(mpiSess.getStdout());
      // outputStdout(mpiSess.getStderr());
      mpiSess.close();
      commands.add(0, Integer.toString(remoteProject.getNp()));
      commands.add(0, GromacsConstants.MPIRUNOPTION);
      commands.add(0, GromacsConstants.MPIRUN);
    }
    String command = ToolBox.createCommandString(commands);

    Session sess = dataHandler.createSession();
    SSHGromacsThread gromacsThread = new SSHGromacsThread(command, sess,
        outStream, interactive, helperStream);
    if (interactive)
      gromacsThread
          .setInputString(inputStringForInteractiveThread(commands
View Full Code Here

      boolean interactive, OutputStream helperStream) throws IOException {
    SSHDataHandler dataHandler = getHandler();
    String gromacsCommand = command.substring(0, command.indexOf(" "));
    if (gromacsCommand.equals(GromacsConstants.MDRUN)
        && remoteProject.isUseMPILib()) {
      Session mpiSess = dataHandler.createSession();
      mpiSess.execCommand(remoteProject.getMpiLib());
      outputSession(mpiSess);
      // outputStdout(mpiSess.getStdout());
      // outputStdout(mpiSess.getStderr());
      mpiSess.close();
      String mpiCommand = GromacsConstants.MPIRUN + " "
          + GromacsConstants.MPIRUNOPTION + " " + remoteProject.getNp()
          + " " + command;
      command = mpiCommand;
    }

    Session sess = dataHandler.createSession();
    SSHGromacsThread gromacsThread = new SSHGromacsThread(command, sess,
        outStream, interactive, helperStream);
    if (interactive)
      gromacsThread
          .setInputString(inputStringForInteractiveThread(gromacsCommand));
View Full Code Here

            if (isAuthenticated == false) {
              s_logger.info("Authentication failed for root with password");
              return false;
            }
           
            Session sess = conn.openSession();
            s_logger.info("Executing : " + commandElement.getTextContent());
            sess.execCommand(commandElement.getTextContent());
            Thread.sleep(60000);
            sess.close();
            conn.close();
           
            } catch (Exception ex) {
              s_logger.error(ex);
              return false;
View Full Code Here

            s_logger.info("Authentication failed for root with password");
            return false;
          }
         
          String restartCommand = "service cloud-management restart; service cloud-usage restart";
          Session sess = conn.openSession();
          s_logger.info("Executing : " + restartCommand);
          sess.execCommand(restartCommand);
          Thread.sleep(120000);
          sess.close();
          conn.close();
         
          } catch (Exception ex) {
            s_logger.error(ex);
            return false;
View Full Code Here

        }
        SCPClient scp = new SCPClient(conn);
       
        scp.put("wget.exe", "");
       
        Session sess = conn.openSession();
        s_logger.info("Executing : wget http://172.16.0.220/dump.bin");
        sess.execCommand("wget http://172.16.0.220/dump.bin && dir dump.bin");
       
        InputStream stdout = sess.getStdout();
        InputStream stderr = sess.getStderr();
       
        byte[] buffer = new byte[8192];
        while (true) {
          if ((stdout.available() == 0) && (stderr.available() == 0)) {
            int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA
                | ChannelCondition.EOF, 120000);
           
            if ((conditions & ChannelCondition.TIMEOUT) != 0) {
              s_logger.info("Timeout while waiting for data from peer.");
              return null;
            }
           
            if ((conditions & ChannelCondition.EOF) != 0) {
              if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
                break;
              }
            }
          }
         
          while (stdout.available() > 0) {
            success = true;
            int len = stdout.read(buffer);
            if (len > 0) // this check is somewhat paranoid
              s_logger.info(new String(buffer, 0, len));
          }
   
          while (stderr.available() > 0) {
            int len = stderr.read(buffer);
          }
        }
        sess.close();
        conn.close();
       
        if (success) {
          return null;
        } else {
View Full Code Here

   
        if (isAuthenticated == false) {
          return "Authentication failed";
        }
        boolean success = false;
        Session sess = conn.openSession();
        s_logger.info("Executing : wget http://172.16.0.220/dump.bin");
        sess.execCommand("wget http://172.16.0.220/dump.bin && ls -al dump.bin");
       
        InputStream stdout = sess.getStdout();
        InputStream stderr = sess.getStderr();
       
        byte[] buffer = new byte[8192];
        while (true) {
          if ((stdout.available() == 0) && (stderr.available() == 0)) {
            int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA
                | ChannelCondition.EOF, 120000);
           
            if ((conditions & ChannelCondition.TIMEOUT) != 0) {
              s_logger.info("Timeout while waiting for data from peer.");
              return null;
            }
           
            if ((conditions & ChannelCondition.EOF) != 0) {
              if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
                break;
              }
            }
          }
         
          while (stdout.available() > 0) {
            success = true;
            int len = stdout.read(buffer);
            if (len > 0) // this check is somewhat paranoid
              s_logger.info(new String(buffer, 0, len));
          }
   
          while (stderr.available() > 0) {
            int len = stderr.read(buffer);
          }
        }
       
        sess.close();
        conn.close();
       
        if (success) {
          return null;
        } else {
View Full Code Here

                }

                if (conn == null) {
                    s_logger.error("Connection is null");
                }
                Session sess = conn.openSession();

                s_logger.info("User + " + _account.get() + " executing : wget http://" + downloadUrl);
                String downloadCommand = "wget http://" + downloadUrl + " && dir dump.bin";
                sess.execCommand(downloadCommand);

                InputStream stdout = sess.getStdout();
                InputStream stderr = sess.getStderr();

                byte[] buffer = new byte[8192];
                while (true) {
                    if ((stdout.available() == 0) && (stderr.available() == 0)) {
                        int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA | ChannelCondition.EOF, 120000);

                        if ((conditions & ChannelCondition.TIMEOUT) != 0) {
                            s_logger.info("Timeout while waiting for data from peer.");
                            return null;
                        }

                        if ((conditions & ChannelCondition.EOF) != 0) {
                            if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
                                break;
                            }
                        }
                    }

                    while (stdout.available() > 0) {
                        success = true;
                        int len = stdout.read(buffer);
                        if (len > 0) // this check is somewhat paranoid
                            s_logger.info(new String(buffer, 0, len));
                    }

                    while (stderr.available() > 0) {
                        /* int len = */stderr.read(buffer);
                    }
                }
                sess.close();
                conn.close();

                if (success) {
                    return null;
                } else {
View Full Code Here

                if (i % 10 == 0)
                    linuxCommand = "rm -rf *; wget http://" + downloadUrl + " && ls -al dump.bin";
                else
                    linuxCommand = "wget http://" + downloadUrl + " && ls -al dump.bin";

                Session sess = conn.openSession();
                s_logger.info("User " + _account.get() + " executing : " + linuxCommand);
                sess.execCommand(linuxCommand);

                InputStream stdout = sess.getStdout();
                InputStream stderr = sess.getStderr();

                byte[] buffer = new byte[8192];
                while (true) {
                    if ((stdout.available() == 0) && (stderr.available() == 0)) {
                        int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA | ChannelCondition.EOF, 120000);

                        if ((conditions & ChannelCondition.TIMEOUT) != 0) {
                            s_logger.info("Timeout while waiting for data from peer.");
                            return null;
                        }

                        if ((conditions & ChannelCondition.EOF) != 0) {
                            if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
                                break;
                            }
                        }
                    }

                    while (stdout.available() > 0) {
                        success = true;
                        int len = stdout.read(buffer);
                        if (len > 0) // this check is somewhat paranoid
                            s_logger.info(new String(buffer, 0, len));
                    }

                    while (stderr.available() > 0) {
                        /* int len = */stderr.read(buffer);
                    }
                }

                sess.close();
                conn.close();

                if (!success) {
                    retry++;
                    if (retry == MAX_RETRY_LINUX) {
View Full Code Here

                }

                if (conn == null ){
                    s_logger.error("Connection is null");
                }
                Session sess = conn.openSession();

                s_logger.info("User + " + _account.get() + " executing : wget http://192.168.1.250/dump.bin");
                sess
                .execCommand("wget http://192.168.1.250/dump.bin && dir dump.bin");

                InputStream stdout = sess.getStdout();
                InputStream stderr = sess.getStderr();

                byte[] buffer = new byte[8192];
                while (true) {
                    if ((stdout.available() == 0) && (stderr.available() == 0)) {
                        int conditions = sess.waitForCondition(
                                ChannelCondition.STDOUT_DATA
                                | ChannelCondition.STDERR_DATA
                                | ChannelCondition.EOF, 120000);

                        if ((conditions & ChannelCondition.TIMEOUT) != 0) {
                            s_logger
                            .info("Timeout while waiting for data from peer.");
                            return null;
                        }

                        if ((conditions & ChannelCondition.EOF) != 0) {
                            if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
                                break;
                            }
                        }
                    }

                    while (stdout.available() > 0) {
                        success = true;
                        int len = stdout.read(buffer);
                        if (len > 0) // this check is somewhat paranoid
                            s_logger.info(new String(buffer, 0, len));
                    }

                    while (stderr.available() > 0) {
                        /* int len = */stderr.read(buffer);
                    }
                }
                sess.close();
                conn.close();

                if (success) {
                    Thread.sleep(120000);
                    return null;
View Full Code Here

TOP

Related Classes of com.trendmicro.mist.client.MistClient$Session

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.