001 /**
002 *
003 */
004 package de.jw.cloud42.webservice;
005
006
007 import de.jw.cloud42.core.domain.AwsCredentials;
008 import de.jw.cloud42.core.domain.RemoteResult;
009 import de.jw.cloud42.core.remoting.RemoteControl;
010
011 /**
012 * Service class for Remoting Service, provides methods to execute arbitrary commands on an AMI instance.
013 *
014 * @author fbitzer
015 *
016 */
017 public class Cloud42RemotingService {
018
019 /**
020 * Executes the given command on the given remote host.
021 * @param dnsName Hostname or IP address of the target AMI instance.
022 * @param rsaKey RSA private key as String.
023 * @param command the command to execute.
024 * @return RemoteResult object containing the output of the command.
025 */
026 public RemoteResult executeCommand(String dnsName, String rsaKey, String command){
027
028 RemoteControl c = new RemoteControl();
029
030 return c.executeCommand(dnsName, rsaKey, command);
031
032 }
033
034
035 /**
036 * Executes a batch file / shell script on the instance.
037 * @param dnsName Hostname or IP address of the target AMI instance.
038 * @param rsaKey RSA private key as String.
039 * @param batchFile Shellscript to execute. Transferred as SOAP attachment using MTOM.
040 * @return RemoteResult object containing the output of the script.
041 */
042 public RemoteResult executeBatch(String dnsName, String rsaKey, byte[] batchFile){
043
044 RemoteControl c = new RemoteControl();
045
046 return c.executeBatch(dnsName, rsaKey, batchFile);
047
048 }
049
050
051 /**
052 * Bundles a new image from a running AMI.
053 *
054 * @param dnsName Hostname of AMI to bundle.
055 * @param rsaKey RSA private key to connect to AMI instance.
056 * @param credentials AWS credentials.
057 * @param targetBucket Bucket on S3 where new AMI should be stored.
058 * @param newImageName Name of new image.
059 * @param is64Bit Set to true, if a 64 bit image should be created.
060 * @param notifyWhenFinished Trigger a notification message when bundling has finished.
061 * @param topic Topic for the notification.
062 * @param messageText Notification text.
063 * @param messageInfo Additional notification information.
064 * @param keyFile The user's private key file for authorization at the EC2 API.
065 * @param certFile The user's certificate file for authorization at the EC2 API.
066 * @return RemoteResult object indicating success or an exception.
067 */
068 public RemoteResult bundleImage(String dnsName, String rsaKey, AwsCredentials credentials,
069 String targetBucket, String newImageName, boolean is64Bit,
070 boolean notifyWhenFinished, String topic, String messageText, String messageInfo,
071 byte[] keyFile, byte[] certFile){
072
073 RemoteControl c = new RemoteControl();
074
075 return c.bundleImage(dnsName, rsaKey, credentials, targetBucket, newImageName, is64Bit,
076 notifyWhenFinished, topic, messageText, messageInfo,
077 keyFile, certFile);
078 }
079
080 }