de.jw.cloud42.core.remoting
Class RemoteControl

java.lang.Object
  extended by de.jw.cloud42.core.remoting.RemoteControl

public class RemoteControl
extends java.lang.Object

Class providing methods for remote control of AMI instances by using SSH. Also contains methods for up- and downloading files .

Author:
fbitzer

Constructor Summary
RemoteControl()
           
 
Method Summary
 RemoteResult bundleImage(java.lang.String dnsName, java.lang.String key, AwsCredentials credentials, java.lang.String targetBucket, java.lang.String newImageName, boolean use64Bit, boolean notifyWhenFinished, java.lang.String topic, java.lang.String messageText, java.lang.String messageInfo, byte[] keyFile, byte[] certFile)
          Bundle a new AMI from an existing one by executing the neccessary statements.
 byte[] downloadFile(java.lang.String host, java.lang.String key, java.lang.String remoteFileName)
          Download a file from a remote host.
 RemoteResult executeBatch(java.lang.String host, java.lang.String key, byte[] batchData)
          Executes a batch file / shell script on the instance.
 RemoteResult executeCommand(java.lang.String host, java.lang.String key, java.lang.String command)
          Executes the given command on the given remote host.
 RemoteResult uploadFile(java.lang.String host, java.lang.String key, java.lang.String targetDir, java.lang.String targetFilename, byte[] fileData)
          Uploads a file to an AMI instance.
 RemoteResult uploadFileFromURL(java.lang.String host, java.lang.String key, java.lang.String targetDir, java.lang.String targetFilename, java.lang.String url)
          Uploads a file to an AMI instance from a given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteControl

public RemoteControl()
Method Detail

executeCommand

public RemoteResult executeCommand(java.lang.String host,
                                   java.lang.String key,
                                   java.lang.String command)
Executes the given command on the given remote host.

Parameters:
host - Hostname or IP address of the target AMI instance.
key - RSA private key as String.
command - the command to execute.
Returns:
RemoteResult object containing the output of the command.

executeBatch

public RemoteResult executeBatch(java.lang.String host,
                                 java.lang.String key,
                                 byte[] batchData)
Executes a batch file / shell script on the instance.

Parameters:
host - Hostname or IP address of the target AMI instance.
key - RSA private key as String.
batchData - Shellscript to execute.
Returns:
RemoteResult object containing the output of the script.

uploadFile

public RemoteResult uploadFile(java.lang.String host,
                               java.lang.String key,
                               java.lang.String targetDir,
                               java.lang.String targetFilename,
                               byte[] fileData)
Uploads a file to an AMI instance.

Parameters:
host - Hostname or IP address of remote host.
key - RSA private key to use for authentification.
targetDir - Target folder on remote machine.
targetFilename - Target filename on remote machine.
fileData - The uploaded file.
Returns:
a RemoteResult encaplsulating error messages.

uploadFileFromURL

public RemoteResult uploadFileFromURL(java.lang.String host,
                                      java.lang.String key,
                                      java.lang.String targetDir,
                                      java.lang.String targetFilename,
                                      java.lang.String url)
Uploads a file to an AMI instance from a given URL. Can be used to transfer files from S3 to an EC2 instance. Uses wget for file transfer.

Parameters:
host - Hostname or IP address of remote host.
key - RSA private key to use for authentification.
targetDir - Target folder on remote machine.
targetFilename - Target filename on remote machine.
url - URL of file to transfer.
Returns:
a RemoteResult encaplsulating the output of the wget command.

downloadFile

public byte[] downloadFile(java.lang.String host,
                           java.lang.String key,
                           java.lang.String remoteFileName)
Download a file from a remote host.

Parameters:
host - Hostname.
key - RSA key to use.
remoteFileName - Absolute filename of file to download.
Returns:
File as byte array.

bundleImage

public RemoteResult bundleImage(java.lang.String dnsName,
                                java.lang.String key,
                                AwsCredentials credentials,
                                java.lang.String targetBucket,
                                java.lang.String newImageName,
                                boolean use64Bit,
                                boolean notifyWhenFinished,
                                java.lang.String topic,
                                java.lang.String messageText,
                                java.lang.String messageInfo,
                                byte[] keyFile,
                                byte[] certFile)
Bundle a new AMI from an existing one by executing the neccessary statements.

Parameters:
dnsName -
key -
credentials -
targetBucket -
newImageName -
use64Bit -
notifyWhenFinished -
messageText -
messageInfo -
keyFile -
certFile -
Returns:
RemoteResult with ExceptionMessage in case of error. Output of the single statements is NOT transferred.


Copyright © 2010 just works! Software. All Rights Reserved.