Brooklyn

brooklyn.util.internal.ssh
[Java] Class SshjTool

java.lang.Object
  brooklyn.util.internal.ssh.SshjTool
All Implemented Interfaces:
SshTool

public class SshjTool

Licensed to jclouds, Inc. (jclouds) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. jclouds licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Nested Class Summary
static class SshjTool.Builder

static interface SshjTool.SshAction

 
Method Summary
java.lang.Object SshjTool(java.util.Map map)

protected java.lang.Object acquire(C connection)

protected void allocatePTY(Session s)

static SshjTool.Builder builder()

void connect()

void connect(int maxAttempts)

int copyToServer(java.util.Map props, java.io.File f, java.lang.String pathAndFileOnRemoteServer)

int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.io.InputStream input, long size)

int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.lang.String contents)

Creates the given file with the given contents.

int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, byte[] contents)

Creates the given file with the given contents.

void disconnect()

int execCommands(java.util.Map props, java.util.List commands)

int execCommands(java.util.Map props, java.util.List commands, java.util.Map env)

int execScript(java.util.Map props, java.util.List commands)

int execScript(java.util.Map props, java.util.List commands, java.util.Map env)

This creates a script containing the user's commands, copies it to the remote server, and executes the script.

int execShell(java.util.Map props, java.util.List commands)

int execShell(java.util.Map props, java.util.List commands, java.util.Map env)

int execShellDirect(java.util.Map props, java.util.List commands, java.util.Map env)

java.lang.String getHostAddress()

java.lang.String getUsername()

boolean isConnected()

protected SshjTool.SshAction newSessionAction()

java.lang.String toString()

int transferFileFrom(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.lang.String pathAndFileOnLocalServer)

int transferFileTo(java.util.Map props, java.io.InputStream input, java.lang.String pathAndFileOnRemoteServer)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

SshjTool

public java.lang.Object SshjTool(java.util.Map map)


acquire

protected java.lang.Object acquire(C connection)


allocatePTY

protected void allocatePTY(Session s)


builder

public static SshjTool.Builder builder()


connect

@Override
public void connect()


connect

@Override
public void connect(int maxAttempts)


copyToServer

@Override
public int copyToServer(java.util.Map props, java.io.File f, java.lang.String pathAndFileOnRemoteServer)


createFile

@Override
public int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.io.InputStream input, long size)


createFile

@Override
public int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.lang.String contents)
Creates the given file with the given contents. Permissions specified using 'permissions:0755'.


createFile

@Override
public int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, byte[] contents)
Creates the given file with the given contents. Permissions specified using 'permissions:0755'.


disconnect

@Override
public void disconnect()


execCommands

@Override
public int execCommands(java.util.Map props, java.util.List commands)


execCommands

@Override
public int execCommands(java.util.Map props, java.util.List commands, java.util.Map env)


execScript

@Override
public int execScript(java.util.Map props, java.util.List commands)


execScript

@Override
public int execScript(java.util.Map props, java.util.List commands, java.util.Map env)
This creates a script containing the user's commands, copies it to the remote server, and executes the script. The script is then deleted.

Executing commands directly is fraught with dangers! Here are other options, and their problems:

So on balance, the script-based approach seems most reliable, even if there is an overhead of separate message(s) for copying the file!


execShell

public int execShell(java.util.Map props, java.util.List commands)


execShell

public int execShell(java.util.Map props, java.util.List commands, java.util.Map env)


execShellDirect

public int execShellDirect(java.util.Map props, java.util.List commands, java.util.Map env)


getHostAddress

public java.lang.String getHostAddress()


getUsername

public java.lang.String getUsername()


isConnected

@Override
public boolean isConnected()


newSessionAction

protected SshjTool.SshAction newSessionAction()


toString

@Override
public java.lang.String toString()


transferFileFrom

@Override
public int transferFileFrom(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.lang.String pathAndFileOnLocalServer)


transferFileTo

@Override
public int transferFileTo(java.util.Map props, java.io.InputStream input, java.lang.String pathAndFileOnRemoteServer)


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.