Package com.vmware.bdd.utils

Examples of com.vmware.bdd.utils.SSHUtil


   private boolean removeSSHLimit() throws Exception {
      String scriptFileName = Configuration.getString(Constants.REMOVE_SSH_LIMIT_SCRIPT, Constants.DEFAULT_REMOVE_SSH_LIMIT_SCRIPT);
      String script = getScriptName(scriptFileName);
      String cmd = "sudo " + script;
      boolean succeed = false;
      SSHUtil sshUtil = new SSHUtil();
      for (int i = 0; i < Constants.SET_PASSWORD_MAX_RETRY_TIMES; i++) {
         try {
            succeed = sshUtil.execCmd(sshUser, privateKeyFile, nodeIP, sshPort, cmd, null, null);
            if (succeed) {
               logger.info("Remove ssh limit for " + nodeIP + " succceed");
               return true;
            }
         } catch (JSchException e) {
View Full Code Here


   private boolean setPassword(String cmd, InputStream in) throws Exception {
      boolean setPasswordSucceed = false;
      int jschExceptionCount = 0;
      for (int i = 0; i < Constants.SET_PASSWORD_MAX_RETRY_TIMES; i++) {
         try {
            SSHUtil sshUtil = new SSHUtil();
            setPasswordSucceed = sshUtil.execCmd(sshUser, privateKeyFile, nodeIP, sshPort, cmd, in, null);
         } catch (JSchException e) {
            if (++jschExceptionCount == Constants.SET_PASSWORD_MAX_RETRY_TIMES) {
               throw SetPasswordException.GOT_JSCH_EXCEPTION_WHEN_SET_PASSWORD(e, nodeIP);
            }
         }
View Full Code Here

   }

   private void refreshTty() {
      String ttyName = Configuration.getString(Constants.SERENGETI_TTY_NAME, Constants.SERENGETI_DEFAULT_TTY_NAME);
      String cmd = "ps aux | grep " + ttyName + " | grep -v \"grep\" | awk '{print $2}' | sudo xargs kill -9";
      SSHUtil sshUtil = new SSHUtil();
      //if refresh failed, user still can manually refresh tty by Ctrl+C, so don't need to check whether
      //it succeed or not
      try {
         boolean refreshTtySucceed = sshUtil.execCmd(sshUser, privateKeyFile, nodeIP, sshPort, cmd, null, null);
         logger.info("Refresh " + ttyName + " on " + nodeIP + (refreshTtySucceed ? "succeed" : "failed") + ".");
      } catch (JSchException e) {
         logger.error("Got exception when refresh tty on " + nodeIP, e);
      }
   }
View Full Code Here

      String setupTtyScriptName = Configuration.getString(Constants.SERENGETI_SETUP_LOGIN_TTY_SCRIPT, Constants.SERENGETI_DEFAULT_SETUP_LOGIN_TTY_SCRIPT);
      String setupTtyScript = getScriptName(setupTtyScriptName);
      String cmd = "sudo " + setupTtyScript;
      String action = "Setup login tty for " + nodeIP;
      logger.info(action + " command is: " + cmd);
      SSHUtil sshUtil = new SSHUtil();
      String errMsg = null;
      for (int i = 0; i < Constants.SET_PASSWORD_MAX_RETRY_TIMES; i++) {
         try {
            if (sshUtil.execCmd(sshUser, privateKeyFile, nodeIP, sshPort, cmd, null, null)) {
               logger.info(action + " succeed.");
               return;
            }
         } catch (JSchException e) {
            logger.warn("Got exception when " + action, e);
View Full Code Here

TOP

Related Classes of com.vmware.bdd.utils.SSHUtil

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.