Package org.platformlayer.ops.ssh

Examples of org.platformlayer.ops.ssh.SshConnection$ProcessStartListener


  private SshConnection getSshConnection(String host, String user, KeyPair sshKeyPair) throws OpsException {
    OpsSystem opsSystem = OpsContext.get().getOpsSystem();
    ISshContext sshContext = opsSystem.getSshContext();

    SshConnection sshConnection = sshContext.getSshConnection(user);
    try {
      sshConnection.setHost(InetAddress.getByName(host));
    } catch (UnknownHostException e) {
      throw new OpsException("Error resolving address: " + host, e);
    }

    sshConnection.setKeyPair(sshKeyPair);

    // TODO: Verify the server key once we've learned it
    IServerKeyVerifier serverKeyVerifier = new AcceptAllLearningServerKeyVerifier();
    sshConnection.setServerKeyVerifier(serverKeyVerifier);

    return sshConnection;
  }
View Full Code Here


    try {
      String commandString = command.buildCommandString();
      TimeSpan timeout = command.getTimeout();

      if (command.getKeyPair() != null) {
        SshConnection agentConnection = sshConnection.buildAgentConnection(command.getKeyPair());
        try {
          return agentConnection.sshExecute(commandString, timeout);
        } finally {
          agentConnection.close();
        }
      } else {
        return sshConnection.sshExecute(commandString, timeout);
      }
    } catch (IOException e) {
View Full Code Here

  @Override
  public OpsTarget getTarget(String user, KeyPair sshKeyPair) throws OpsException {
    OpsSystem opsSystem = OpsContext.get().getOpsSystem();
    ISshContext sshContext = opsSystem.getSshContext();

    SshConnection sshConnection = sshContext.getSshConnection(user);

    String address = getNetworkPoint().getBestAddress(NetworkPoint.forMe());
    try {
      sshConnection.setHost(InetAddress.getByName(address));
    } catch (UnknownHostException e) {
      throw new OpsException("Error resolving address: " + address, e);
    }

    sshConnection.setKeyPair(sshKeyPair);

    File tempDirBase = new File("/tmp/");

    // TODO: Verify the server key once we've learned it
    IServerKeyVerifier serverKeyVerifier = new AcceptAllLearningServerKeyVerifier();
    sshConnection.setServerKeyVerifier(serverKeyVerifier);
    return new SshOpsTarget(tempDirBase, this, sshConnection);
  }
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.ssh.SshConnection$ProcessStartListener

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.