org.jclouds.aws.ec2.compute
Class AWSEC2ComputeService

java.lang.Object
  extended by org.jclouds.compute.internal.BaseComputeService
      extended by org.jclouds.ec2.compute.EC2ComputeService
          extended by org.jclouds.aws.ec2.compute.AWSEC2ComputeService
All Implemented Interfaces:
ComputeService

@Singleton
public class AWSEC2ComputeService
extends EC2ComputeService

Author:
Adrian Cole

Field Summary
 
Fields inherited from class org.jclouds.compute.internal.BaseComputeService
context, credentialStore, logger
 
Constructor Summary
protected AWSEC2ComputeService(ComputeServiceContext context, Map<String,Credentials> credentialStore, com.google.common.base.Supplier<Set<? extends Image>> images, com.google.common.base.Supplier<Set<? extends Hardware>> sizes, com.google.common.base.Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy, SuspendNodeStrategy stopNodeStrategy, javax.inject.Provider<TemplateBuilder> templateBuilderProvider, javax.inject.Provider<TemplateOptions> templateOptionsProvider, com.google.common.base.Predicate<NodeMetadata> nodeRunning, com.google.common.base.Predicate<NodeMetadata> nodeTerminated, com.google.common.base.Predicate<NodeMetadata> nodeSuspended, InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess, PersistNodeCredentials persistNodeCredentials, ComputeServiceConstants.Timeouts timeouts, ExecutorService executor, AWSEC2Client ec2Client, ConcurrentMap<RegionAndName,KeyPair> credentialsMap, com.google.common.cache.Cache<RegionAndName,String> securityGroupMap, com.google.common.cache.Cache<RegionAndName,String> placementGroupMap, com.google.common.base.Predicate<PlacementGroup> placementGroupDeleted, boolean generateInstanceNames, AWSEC2AsyncClient aclient)
           
 
Method Summary
protected  void addTagsToNodesFromUserMetadataInTemplate(Set<? extends NodeMetadata> nodes, String group, Template template)
           
protected  Set<? extends NodeMetadata> addUserMetadataFromTemplateOptionsToNodes(Template template, String group, Set<? extends NodeMetadata> nodes)
           
protected  void cleanUpIncidentalResources(Map.Entry<String,String> regionTag)
           
 Set<? extends NodeMetadata> createNodesInGroup(String group, int count, Template template)
          The compute api treats nodes as a group based on the name you specify.
 EC2TemplateOptions templateOptions()
          returns template options, except of type EC2TemplateOptions.
protected  boolean templateWasASpotRequestWithUserMetadata(Template template)
           
 
Methods inherited from class org.jclouds.ec2.compute.EC2ComputeService
destroyNodesMatching, extractIdsFromInstances, usingKeyPairAndNotDead
 
Methods inherited from class org.jclouds.compute.internal.BaseComputeService
createNodesInGroup, createNodesInGroup, destroyNode, getContext, getNodeMetadata, listAssignableLocations, listHardwareProfiles, listImages, listNodes, listNodesDetailsMatching, rebootNode, rebootNodesMatching, resumeNode, resumeNodesMatching, runNodesWithTag, runNodesWithTag, runNodesWithTag, runScriptOnNode, runScriptOnNode, runScriptOnNode, runScriptOnNode, runScriptOnNodesMatching, runScriptOnNodesMatching, runScriptOnNodesMatching, runScriptOnNodesMatching, runScriptOnNodesMatching, runScriptOnNodesMatching, submitScriptOnNode, suspendNode, suspendNodesMatching, templateBuilder, updateNodeWithCredentialsIfPresent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AWSEC2ComputeService

@Inject
protected AWSEC2ComputeService(ComputeServiceContext context,
                                      Map<String,Credentials> credentialStore,
                                      com.google.common.base.Supplier<Set<? extends Image>> images,
                                      com.google.common.base.Supplier<Set<? extends Hardware>> sizes,
                                      com.google.common.base.Supplier<Set<? extends Location>> locations,
                                      ListNodesStrategy listNodesStrategy,
                                      GetNodeMetadataStrategy getNodeMetadataStrategy,
                                      CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
                                      RebootNodeStrategy rebootNodeStrategy,
                                      DestroyNodeStrategy destroyNodeStrategy,
                                      ResumeNodeStrategy startNodeStrategy,
                                      SuspendNodeStrategy stopNodeStrategy,
                                      javax.inject.Provider<TemplateBuilder> templateBuilderProvider,
                                      javax.inject.Provider<TemplateOptions> templateOptionsProvider,
                                      @Named(value="NODE_RUNNING")
                                      com.google.common.base.Predicate<NodeMetadata> nodeRunning,
                                      @Named(value="NODE_TERMINATED")
                                      com.google.common.base.Predicate<NodeMetadata> nodeTerminated,
                                      @Named(value="NODE_SUSPENDED")
                                      com.google.common.base.Predicate<NodeMetadata> nodeSuspended,
                                      InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
                                      RunScriptOnNode.Factory runScriptOnNodeFactory,
                                      InitAdminAccess initAdminAccess,
                                      PersistNodeCredentials persistNodeCredentials,
                                      ComputeServiceConstants.Timeouts timeouts,
                                      @Named(value="jclouds.user-threads")
                                      ExecutorService executor,
                                      AWSEC2Client ec2Client,
                                      ConcurrentMap<RegionAndName,KeyPair> credentialsMap,
                                      @Named(value="SECURITY")
                                      com.google.common.cache.Cache<RegionAndName,String> securityGroupMap,
                                      @Named(value="PLACEMENT")
                                      com.google.common.cache.Cache<RegionAndName,String> placementGroupMap,
                                      @Named(value="DELETED")
                                      com.google.common.base.Predicate<PlacementGroup> placementGroupDeleted,
                                      @Named(value="jclouds.ec2.generate-instance-names")
                                      boolean generateInstanceNames,
                                      AWSEC2AsyncClient aclient)
Method Detail

createNodesInGroup

public Set<? extends NodeMetadata> createNodesInGroup(String group,
                                                      int count,
                                                      Template template)
                                               throws RunNodesException
Description copied from interface: ComputeService
The compute api treats nodes as a group based on the name you specify. Using this group, you can choose to operate one or many nodes as a logical unit without regard to the implementation details of the cloud.

The set that is returned will include credentials you can use to ssh into the nodes. The "key" part of the credentials is either a password or a private key. You have to inspect the value to determine this.

 if (node.getCredentials().key.startsWith("-----BEGIN RSA PRIVATE KEY-----"))
    // it is a private key, not a password.
 

Note. if all you want to do is execute a script at bootup, you should consider use of the runscript option.

If resources such as security groups are needed, they will be reused or created for you. Inbound port 22 will always be opened up.

Specified by:
createNodesInGroup in interface ComputeService
Overrides:
createNodesInGroup in class BaseComputeService
Parameters:
group - - common identifier to group nodes by, cannot contain hyphens
count - - how many to fire up.
template - - how to configure the nodes
Returns:
all of the nodes the api was able to launch in a running state.
Throws:
RunNodesException - when there's a problem applying options to nodes. Note that successful and failed nodes are a part of this exception, so be sure to inspect this carefully.

addTagsToNodesFromUserMetadataInTemplate

protected void addTagsToNodesFromUserMetadataInTemplate(Set<? extends NodeMetadata> nodes,
                                                        String group,
                                                        Template template)

templateWasASpotRequestWithUserMetadata

protected boolean templateWasASpotRequestWithUserMetadata(Template template)

addUserMetadataFromTemplateOptionsToNodes

protected Set<? extends NodeMetadata> addUserMetadataFromTemplateOptionsToNodes(Template template,
                                                                                String group,
                                                                                Set<? extends NodeMetadata> nodes)

cleanUpIncidentalResources

protected void cleanUpIncidentalResources(Map.Entry<String,String> regionTag)
Overrides:
cleanUpIncidentalResources in class EC2ComputeService

templateOptions

public EC2TemplateOptions templateOptions()
returns template options, except of type EC2TemplateOptions.

Specified by:
templateOptions in interface ComputeService
Overrides:
templateOptions in class EC2ComputeService


Copyright © 2009-2011 jclouds. All Rights Reserved.