Package org.jclouds.ec2.compute
Class EC2ComputeService
java.lang.Object
org.jclouds.compute.internal.BaseComputeService
org.jclouds.ec2.compute.EC2ComputeService
- All Implemented Interfaces:
ComputeService
- Direct Known Subclasses:
AWSEC2ComputeService
-
Field Summary
Fields inherited from class org.jclouds.compute.internal.BaseComputeService
context, credentialStore, logger
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
EC2ComputeService
(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, GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy, SuspendNodeStrategy stopNodeStrategy, jakarta.inject.Provider<TemplateBuilder> templateBuilderProvider, jakarta.inject.Provider<TemplateOptions> templateOptionsProvider, com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeRunning, com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeTerminated, com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeSuspended, InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess, PersistNodeCredentials persistNodeCredentials, ComputeServiceConstants.Timeouts timeouts, com.google.common.util.concurrent.ListeningExecutorService userExecutor, EC2Api client, ConcurrentMap<RegionAndName, KeyPair> credentialsMap, com.google.common.cache.LoadingCache<RegionAndName, String> securityGroupMap, com.google.common.base.Optional<ImageExtension> imageExtension, GroupNamingConvention.Factory namingConvention, boolean generateInstanceNames, com.google.common.base.Optional<SecurityGroupExtension> securityGroupExtension, DelegatingImageExtension.Factory delegatingImageExtension) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cleanUpIncidentalResources
(String region, String group) protected void
cleanUpIncidentalResourcesOfDeadNodes
(Set<? extends NodeMetadata> deadNodes) Cleans implicit keypairs and security groups.Set
<? extends NodeMetadata> createNodesInGroup
(String group, int count, Template template) The compute api treats nodes as a group based on the name you specify.protected com.google.common.collect.ImmutableSet
<String> extractIdsFromInstances
(Iterable<? extends RunningInstance> deadOnes) returns template options, except of typeEC2TemplateOptions
.Methods inherited from class org.jclouds.compute.internal.BaseComputeService
createNodesInGroup, createNodesInGroup, destroyNode, destroyNodesMatching, doDestroyNode, getContext, getImage, getImageExtension, getNodeMetadata, getSecurityGroupExtension, listAssignableLocations, listHardwareProfiles, listImages, listNodes, listNodesByIds, listNodesDetailsMatching, rebootNode, rebootNodesMatching, resumeNode, resumeNodesMatching, runScriptOnNode, runScriptOnNode, runScriptOnNode, runScriptOnNode, runScriptOnNodesMatching, runScriptOnNodesMatching, runScriptOnNodesMatching, runScriptOnNodesMatching, submitScriptOnNode, submitScriptOnNode, suspendNode, suspendNodesMatching, templateBuilder, updateNodeWithCredentialsIfPresent
-
Constructor Details
-
EC2ComputeService
@Inject protected EC2ComputeService(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, GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy, SuspendNodeStrategy stopNodeStrategy, jakarta.inject.Provider<TemplateBuilder> templateBuilderProvider, @Named("DEFAULT") jakarta.inject.Provider<TemplateOptions> templateOptionsProvider, @Named("jclouds.compute.timeout.node-running") com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeRunning, @Named("jclouds.compute.timeout.node-terminated") com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeTerminated, @Named("jclouds.compute.timeout.node-suspended") com.google.common.base.Predicate<AtomicReference<NodeMetadata>> nodeSuspended, InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess, PersistNodeCredentials persistNodeCredentials, ComputeServiceConstants.Timeouts timeouts, @Named("jclouds.user-threads") com.google.common.util.concurrent.ListeningExecutorService userExecutor, EC2Api client, ConcurrentMap<RegionAndName, KeyPair> credentialsMap, @Named("SECURITY") com.google.common.cache.LoadingCache<RegionAndName, String> securityGroupMap, com.google.common.base.Optional<ImageExtension> imageExtension, GroupNamingConvention.Factory namingConvention, @Named("jclouds.ec2.generate-instance-names") boolean generateInstanceNames, com.google.common.base.Optional<SecurityGroupExtension> securityGroupExtension, DelegatingImageExtension.Factory delegatingImageExtension)
-
-
Method Details
-
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.Note
While naming constraints on the group name vary per cloud, lower-case alphanumeric with hyphens and least characters practical is most compatible.- Specified by:
createNodesInGroup
in interfaceComputeService
- Overrides:
createNodesInGroup
in classBaseComputeService
- Parameters:
group
- - common identifier to group nodes bycount
- - 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.
-
extractIdsFromInstances
protected com.google.common.collect.ImmutableSet<String> extractIdsFromInstances(Iterable<? extends RunningInstance> deadOnes) -
cleanUpIncidentalResourcesOfDeadNodes
Cleans implicit keypairs and security groups.- Overrides:
cleanUpIncidentalResourcesOfDeadNodes
in classBaseComputeService
-
cleanUpIncidentalResources
-
templateOptions
returns template options, except of typeEC2TemplateOptions
.- Specified by:
templateOptions
in interfaceComputeService
- Overrides:
templateOptions
in classBaseComputeService
-