AEC2
- java.lang.Object
-
- com.dashoptimization.AEC2
-
public class AEC2 extends java.lang.Object
-
-
Field Summary
Modifier and Type Field and Description java.lang.StringconnectionModeDefault connection mode (xprmsrv or ssh).java.lang.StringimageThe AMI Id used when starting a new instance.java.lang.StringinstanceTypeThe instance type used when starting a new instance.java.lang.StringsecurityGroupThe name of the security group used when starting a new instance.intxsrvPortPort used by xprmsrv.
-
Constructor Summary
Constructor and Description AEC2()
-
Method Summary
Modifier and Type Method and Description java.util.List<AEC2Instance>getAllInstances()Retrieve from AWS the list of running (or recently terminated) instances.voidloadConfig(java.lang.String fname)Load a config file written by MoselAEC2InstancerunInstance()Run a new instance using the current settingsvoidsetCredentials(java.lang.String uid, java.lang.String passwd)Set AWS CredentialsvoidsetEndPoint(java.lang.String ep)Set EndPointvoidsetSSHKey(java.lang.String k, java.lang.String kdata)Set SSH keysstatic booleantcpPing(java.lang.String hostname, int port)Test whether a remote host accepts connections on a given port
-
-
-
Field Detail
-
image
public java.lang.String image
The AMI Id used when starting a new instance. This parameter is initialised byloadConfig(java.lang.String)
-
instanceType
public java.lang.String instanceType
The instance type used when starting a new instance. This parameter is initialised byloadConfig(java.lang.String). Possible values: m1.small, m1.large, m1.xlarge, c1.medium, c1.xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, cc1.4xlarge, cg1.4xlarge, t1.micro
-
securityGroup
public java.lang.String securityGroup
The name of the security group used when starting a new instance. This parameter is initialised byloadConfig(java.lang.String)
-
connectionMode
public java.lang.String connectionMode
Default connection mode (xprmsrv or ssh). This parameter is initialised byloadConfig(java.lang.String)
-
xsrvPort
public int xsrvPort
Port used by xprmsrv. This parameter is initialised byloadConfig(java.lang.String)
-
-
Method Detail
-
loadConfig
public void loadConfig(java.lang.String fname) throws java.io.IOExceptionLoad a config file written by Mosel- Parameters:
-
fname- file to process - Throws:
-
java.io.IOException- If load fails or the data it contains is not valid
-
setEndPoint
public void setEndPoint(java.lang.String ep) throws java.io.IOExceptionSet EndPoint- Parameters:
-
ep- Endpoint to use - Throws:
-
java.io.IOException- If request to AWS fails
-
setCredentials
public void setCredentials(java.lang.String uid, java.lang.String passwd) throws java.io.IOExceptionSet AWS Credentials- Parameters:
-
uid- User Id -
passwd- password - Throws:
-
java.io.IOException- If the password or use ID is not valid
-
setSSHKey
public void setSSHKey(java.lang.String k, java.lang.String kdata) throws java.io.IOExceptionSet SSH keys- Parameters:
-
k- the key name -
kdata- its secret part - Throws:
-
java.io.IOException- If the file generation fails (the key is saved into a file).
-
runInstance
public AEC2Instance runInstance() throws java.io.IOException
Run a new instance using the current settings- Throws:
-
java.io.IOException
-
getAllInstances
public java.util.List<AEC2Instance> getAllInstances() throws java.io.IOException
Retrieve from AWS the list of running (or recently terminated) instances.- Throws:
-
java.io.IOException
-
tcpPing
public static boolean tcpPing(java.lang.String hostname, int port)Test whether a remote host accepts connections on a given port- Parameters:
-
hostname- host to test -
port- TCP port to test - Returns:
-
trueif connection is possible
-
-
