Package org.jclouds.compute
Interface ComputeService
- All Known Implementing Classes:
AWSEC2ComputeService
,AzureComputeService
,BaseComputeService
,CloudStackComputeService
,EC2ComputeService
,GoGridComputeService
,GoogleComputeEngineService
,NovaComputeService
public interface ComputeService
Provides portable access to launching compute instances.
-
Method Summary
Modifier and TypeMethodDescriptionSet
<? extends NodeMetadata> createNodesInGroup
(String group, int count) LikecreateNodesInGroup(String,int,TemplateOptions)
, except that the options are default, as specified intemplateOptions()
.Set
<? extends NodeMetadata> createNodesInGroup
(String group, int count, Template template) The compute api treats nodes as a group based on the name you specify.Set
<? extends NodeMetadata> createNodesInGroup
(String group, int count, TemplateOptions templateOptions) LikecreateNodesInGroup(String,int,Template)
, except that the template is default, equivalent totemplateBuilder().any().options(templateOptions)
.void
destroyNode
(String id) destroy the node, given its id.Set
<? extends NodeMetadata> destroyNodesMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter) nodes matching the filter are treated as a logical set.Find an image by its id.com.google.common.base.Optional
<ImageExtension> Returns theImageExtension
for this provider if it implements it.Find a node by its id.com.google.common.base.Optional
<SecurityGroupExtension> Returns theSecurityGroupExtension
for this provider if it implements it.The list locations command returns all the valid locations for nodes.The list hardware profiles command shows you the options including virtual cpu count, memory, and disks.Images define the operating system and metadata related to a node.Set
<? extends ComputeMetadata> Set
<? extends ComputeMetadata> listNodesByIds
(Iterable<String> ids) Set
<? extends NodeMetadata> listNodesDetailsMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter) get all nodes including details such as image and ip addresses even if it incurs extra requests to the service.void
rebootNode
(String id) reboot the node, given its id.Set
<? extends NodeMetadata> rebootNodesMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter) nodes matching the filter are treated as a logical set.void
resumeNode
(String id) resume the node frominvalid reference
suspended
Set
<? extends NodeMetadata> resumeNodesMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter) nodes matching the filter are treated as a logical set.runScriptOnNode
(String id, String runScript) runScriptOnNode
(String id, String runScript, RunScriptOptions options) runScriptOnNode
(String id, Statement runScript) runScriptOnNode
(String id, Statement runScript, RunScriptOptions options) Run the script on a specific nodeMap
<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter, String runScript) Map
<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter, String runScript, RunScriptOptions options) Map
<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter, Statement runScript) Map
<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter, Statement runScript, RunScriptOptions options) Run the script on all nodes with the specific predicate.com.google.common.util.concurrent.ListenableFuture
<ExecResponse> submitScriptOnNode
(String id, String runScript, RunScriptOptions options) Run the script on a specific node in the background, typically asnohup
com.google.common.util.concurrent.ListenableFuture
<ExecResponse> submitScriptOnNode
(String id, Statement runScript, RunScriptOptions options) void
suspendNode
(String id) suspend the node, given its id.Set
<? extends NodeMetadata> suspendNodesMatching
(com.google.common.base.Predicate<? super NodeMetadata> filter) nodes matching the filter are treated as a logical set.Makes a new template builder for this serviceMakes a new set of options for running nodes
-
Method Details
-
getContext
ComputeServiceContext getContext()- Returns:
- a reference to the context that created this ComputeService.
-
templateBuilder
TemplateBuilder templateBuilder()Makes a new template builder for this service -
templateOptions
TemplateOptions templateOptions()Makes a new set of options for running nodes -
listHardwareProfiles
The list hardware profiles command shows you the options including virtual cpu count, memory, and disks. cpu count is not a portable quantity across clouds, as they are measured differently. However, it is a good indicator of relative speed within a cloud. memory is measured in megabytes and disks in gigabytes.note
This is a cached collection -
listImages
Images define the operating system and metadata related to a node. In some clouds, Images are bound to a specific region, and their identifiers are different across these regions. For this reason, you should consider matching image requirements like operating system family with TemplateBuilder as opposed to choosing an image explicitly.note
This is a cached collection -
getImage
Find an image by its id.note
This is an uncached call to the backend service -
listNodes
Set<? extends ComputeMetadata> listNodes()- Returns:
- all nodes available to the current user. If possible, the returned set will include
NodeMetadata
objects.
-
listNodesByIds
- Returns:
- all nodes with one of the provided ids available to the current user.
-
listAssignableLocations
The list locations command returns all the valid locations for nodes. A location has a scope, which is typically region or zone. A region is a general area, like eu-west, where a zone is similar to a datacenter. If a location has a parent, that implies it is within that location. For example a location can be a rack, whose parent is likely to be a zone.note
This is a cached collection -
createNodesInGroup
Set<? extends NodeMetadata> createNodesInGroup(String group, int count, Template template) throws RunNodesException 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.- 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.
-
createNodesInGroup
Set<? extends NodeMetadata> createNodesInGroup(String group, int count, TemplateOptions templateOptions) throws RunNodesException LikecreateNodesInGroup(String,int,Template)
, except that the template is default, equivalent totemplateBuilder().any().options(templateOptions)
.- Throws:
RunNodesException
-
createNodesInGroup
LikecreateNodesInGroup(String,int,TemplateOptions)
, except that the options are default, as specified intemplateOptions()
.- Throws:
RunNodesException
-
resumeNode
resume the node frominvalid reference
suspended
note
affected nodes may not resume with the same IP address(es) -
resumeNodesMatching
Set<? extends NodeMetadata> resumeNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter) nodes matching the filter are treated as a logical set. Using the resume command, you can save time by resuming the nodes in parallel.note
affected nodes may not resume with the same IP address(es)- Returns:
- list of nodes resumed
-
suspendNode
suspend the node, given its id. This will result ininvalid reference
suspended
note
affected nodes may not resume with the same IP address(es)- Throws:
UnsupportedOperationException
- if the underlying provider doesn't support suspend/resume
-
suspendNodesMatching
Set<? extends NodeMetadata> suspendNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter) nodes matching the filter are treated as a logical set. Using the suspend command, you can save time by suspending the nodes in parallel.note
affected nodes may not resume with the same IP address(es)- Returns:
- list of nodes suspended
-
destroyNode
destroy the node, given its id. If it is the only node in a tag set, the dependent resources will also be destroyed. -
destroyNodesMatching
Set<? extends NodeMetadata> destroyNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter) nodes matching the filter are treated as a logical set. Using the delete command, you can save time by removing the nodes in parallel. When the last node in a set is destroyed, any indirect resources it uses, such as keypairs, are also destroyed.- Returns:
- list of nodes destroyed
-
rebootNode
reboot the node, given its id. -
rebootNodesMatching
Set<? extends NodeMetadata> rebootNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter) nodes matching the filter are treated as a logical set. Using this command, you can save time by rebooting the nodes in parallel.- Returns:
- list of nodes rebooted
-
getNodeMetadata
Find a node by its id. -
listNodesDetailsMatching
Set<? extends NodeMetadata> listNodesDetailsMatching(com.google.common.base.Predicate<? super NodeMetadata> filter) get all nodes including details such as image and ip addresses even if it incurs extra requests to the service.- Parameters:
filter
- how to select the nodes you are interested in details on.
-
runScriptOnNodesMatching
Map<? extends NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter, String runScript) throws RunScriptOnNodesException - Throws:
RunScriptOnNodesException
- See Also:
-
runScriptOnNodesMatching
Map<? extends NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter, Statement runScript) throws RunScriptOnNodesException - Throws:
RunScriptOnNodesException
- See Also:
-
runScriptOnNodesMatching
Map<? extends NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter, String runScript, RunScriptOptions options) throws RunScriptOnNodesException - Throws:
RunScriptOnNodesException
- See Also:
-
runScriptOnNodesMatching
Map<? extends NodeMetadata,ExecResponse> runScriptOnNodesMatching(com.google.common.base.Predicate<? super NodeMetadata> filter, Statement runScript, RunScriptOptions options) throws RunScriptOnNodesException Run the script on all nodes with the specific predicate.- Parameters:
filter
- Predicate-based filter to define on which nodes the script is to be executedrunScript
- statement containing the script to runoptions
- nullable options to how to run the script, whether to override credentials- Returns:
- map with node identifiers and corresponding responses
- See Also:
-
runScriptOnNode
Run the script on a specific node- Parameters:
id
- node the script is to be executed onrunScript
- statement containing the script to runoptions
- nullable options to how to run the script, whether to override credentials- Returns:
- map with node identifiers and corresponding responses
- See Also:
-
submitScriptOnNode
@Beta com.google.common.util.concurrent.ListenableFuture<ExecResponse> submitScriptOnNode(String id, String runScript, RunScriptOptions options) Run the script on a specific node in the background, typically asnohup
- Parameters:
id
- node the script is to be executed onrunScript
- statement containing the script to runoptions
- nullable options to how to run the script, whether to override credentials- Returns:
- map with node identifiers and corresponding responses
- See Also:
-
submitScriptOnNode
@Beta com.google.common.util.concurrent.ListenableFuture<ExecResponse> submitScriptOnNode(String id, Statement runScript, RunScriptOptions options) -
runScriptOnNode
- See Also:
-
runScriptOnNode
- See Also:
-
runScriptOnNode
- See Also:
-
getImageExtension
Returns theImageExtension
for this provider if it implements it.- Returns:
- an optional of the
ImageExtension
orOptional.absent()
if not implemented
-
getSecurityGroupExtension
Returns theSecurityGroupExtension
for this provider if it implements it.- Returns:
- an optional of the
SecurityGroupExtension
orOptional.absent()
if not implemented
-