@groovy.util.logging.Slf4j @groovy.transform.CompileStatic @ServiceName('aws') class AmazonCloudDriver extends java.lang.Object
Implements the cloud driver of Amazon AWS
Constructor and description |
---|
AmazonCloudDriver
() Initialise the Amazon cloud driver with default (empty) parameters |
AmazonCloudDriver
(java.util.Map config) Initialise the Amazon cloud driver with the specified parameters |
protected AmazonCloudDriver
(com.amazonaws.services.ec2.AmazonEC2Client client) only for testing purpose -- do not use |
Type Params | Return Type | Name and description |
---|---|---|
|
CloudInstanceType |
describeInstanceType(java.lang.String instanceType) Describe an instance type by the given type |
|
void |
eachInstance(groovy.lang.Closure callback) Iterate over the list of available EC2 instances |
|
void |
eachInstanceWithIds(java.util.List<java.lang.String> instanceIds, groovy.lang.Closure callback) Iterate over the list of instances for the given instance IDs |
|
void |
eachInstanceWithTags(java.util.Map tags, groovy.lang.Closure callback) Iterate over the list of instances for the given tags |
|
void |
eachSpotPrice(java.util.List<java.lang.String> instanceTypes, groovy.lang.Closure action) Iterate over list of spot prices for the given instance types |
|
protected java.lang.String |
fetchIamRole() Retrieve the current IAM role eventually define for a EC2 instance. |
|
protected java.lang.String |
fetchRegion() Retrieve the AWS region from the EC2 instance metadata. |
|
protected java.lang.String |
getAccessKey() @return The current set AWS access key |
|
com.amazonaws.services.batch.AWSBatchClient |
getBatchClient() Gets or lazily creates an com.amazonaws.services.batch.AWSBatchClient instance given the current configuration parameter |
|
com.amazonaws.services.ec2.AmazonEC2Client |
getEc2Client() Gets or lazily creates an com.amazonaws.services.ec2.AmazonEC2Client instance given the current configuration parameter |
|
java.lang.String |
getLocalInstanceId() @return The current instance identified |
|
java.lang.String |
getLocalTerminationNotice() Retrieve a termination notice for spot instance notifying the instance is going to be retired. |
|
protected java.lang.String |
getSecretKey() @return The current set AWS secret key |
|
protected java.lang.String |
getUrl(java.lang.String path, int timeout = 150) Fetch a remote URL resource text content |
|
protected java.lang.String |
getsessionToken() @return The current set AWS session key |
|
java.util.List<java.lang.String> |
launchInstances(int instanceCount, LaunchConfig cfg) |
|
java.util.List<java.lang.String> |
listPrivateIPs(java.lang.String clusterName) Retrieve the private IPs of all nodes in the cluster with the specified name |
|
void |
tagInstances(java.util.Collection<java.lang.String> instanceIds, java.util.Map<java.lang.String, java.lang.String> tags) Tag one or more instances with the specified key=value pairs |
|
void |
terminateInstances(java.util.Collection<java.lang.String> instanceIds) Terminate one or more EC2 instances |
|
void |
validate(LaunchConfig config) Validate the cloud configuration object |
|
void |
waitInstanceStatus(java.util.Collection<java.lang.String> instanceIds, CloudInstanceStatus status) Wait for the specified instances reach the specified CloudInstanceStatus |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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() |
Initialise the Amazon cloud driver with default (empty) parameters
Initialise the Amazon cloud driver with the specified parameters
config
- A map holding the driver parameters:
- accessKey: the access key credentials
- secretKey: the secret key credentials
- region: the AWS regiononly for testing purpose -- do not use
Describe an instance type by the given type Note: it's declared as Memoized to avoid to make a remote API call for each invocation
instanceType
- The instance type ID e.g. m3.2xlargenull
if no record is found for the given instance typeIterate over the list of available EC2 instances
callback
- A closure getting a single parameter of type CloudInstance,
representing the action to be applied on each instanceIterate over the list of instances for the given instance IDs
instanceIds
- One or more instance IDscallback
- A closure getting a single parameter of type CloudInstance
describing the properties for the current instanceIterate over the list of instances for the given tags
tags
- One or more tag given as a java.util.Map objectcallback
- A closure getting a single parameter of type CloudInstance
describing the properties for the current instanceIterate over list of spot prices for the given instance types
instanceTypes
- A collection of instance typescallback
- A closure getting a single parameter of type CloudSpotPrice describing
the instance properties and price for the actual instance typeRetrieve the current IAM role eventually define for a EC2 instance. See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#instance-metadata-security-credentials
null
if no role is defined or
it's not a EC2 instanceRetrieve the AWS region from the EC2 instance metadata. See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
eu-west-1
or
null
if it's not an EC2 instance.
Gets or lazily creates an com.amazonaws.services.batch.AWSBatchClient instance given the current configuration parameter
Gets or lazily creates an com.amazonaws.services.ec2.AmazonEC2Client instance given the current configuration parameter
Retrieve a termination notice for spot instance notifying the instance is going to be retired. https://aws.amazon.com/blogs/aws/new-ec2-spot-instance-termination-notices/ http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html
Fetch a remote URL resource text content
path
- A valid http/https resource URLtimeout
- Max connection timeout in millis
Retrieve the private IPs of all nodes in the cluster with the specified name
clusterName
- The name of the cluster for which retrieve the list of IPsTag one or more instances with the specified key=value pairs
instanceIds
- A list of instance IDstags
- A mpa of tags to be associated to the specified instancesTerminate one or more EC2 instances
instanceIds
- A list of instance IDsValidate the cloud configuration object
config
- The LaunchConfig configuration objectWait for the specified instances reach the specified CloudInstanceStatus
instanceIds
- One or more EC2 instance IDs