Exemplo n.º 1
0
  public EngineSSHClient getSSHClient() throws Exception {
    Long timeout =
        TimeUnit.SECONDS.toMillis(
            Config.<Integer>getValue(ConfigValues.ConnectToServerTimeoutInSeconds));

    EngineSSHClient sshclient = new EngineSSHClient();
    sshclient.setVds(getParameters().getvds());
    sshclient.setHardTimeout(timeout);
    sshclient.setSoftTimeout(timeout);
    sshclient.setPassword(getParameters().getPassword());
    switch (getParameters().getAuthMethod()) {
      case PublicKey:
        sshclient.useDefaultKeyPair();
        break;
      case Password:
        sshclient.setPassword(getParameters().getPassword());
        break;
      default:
        throw new Exception("Invalid authentication method value was sent to AddVdsCommand");
    }

    return sshclient;
  }