Package org.jclouds.compute.options
Class TemplateOptions
- java.lang.Object
-
- org.jclouds.compute.options.RunScriptOptions
-
- org.jclouds.compute.options.TemplateOptions
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
AzureTemplateOptions
,CloudStackTemplateOptions
,DigitalOcean2TemplateOptions
,DockerTemplateOptions
,EC2TemplateOptions
,GleSYSTemplateOptions
,GoGridTemplateOptions
,GoogleComputeEngineTemplateOptions
,NovaTemplateOptions
,PacketTemplateOptions
,SoftLayerTemplateOptions
,TemplateOptions.ImmutableTemplateOptions
public class TemplateOptions extends RunScriptOptions implements Cloneable
Contains options supported in theComputeService#createNodesInGroup
operation.Usage
The recommended way to instantiate a TemplateOptions object is to statically import TemplateOptions.* and invoke a static creation method followed by any/all desired instance mutators.import static org.jclouds.compute.options.TemplateOptions.Builder.*; ComputeService client = // get connection templateBuilder.options(inboundPorts(22, 80, 8080, 443)); Set extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
Note that options can only be assigned to a builder once, so if assigning e.g. inboundPorts and tags, that must be done in with mutators in a single call to options --
templateBuilder.options(inboundPorts(22, 80, 8080, 443).tags("I love it!"))
-- not as repeated calls tooptions
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TemplateOptions.Builder
static class
TemplateOptions.ImmutableTemplateOptions
-
Nested classes/interfaces inherited from class org.jclouds.compute.options.RunScriptOptions
RunScriptOptions.ImmutableRunScriptOptions
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
blockUntilRunning
protected Set<Integer>
inboundPorts
protected Set<String>
networks
protected Set<String>
nodeNames
static TemplateOptions
NONE
protected String
privateKey
protected String
publicKey
protected Statement
script
protected Set<String>
securityGroups
protected Set<String>
tags
protected Map<String,String>
userMetadata
-
Fields inherited from class org.jclouds.compute.options.RunScriptOptions
authenticateSudo, blockOnComplete, loginPassword, loginPrivateKey, loginUser, port, runAsRoot, seconds, taskName, wrapInInitScript
-
-
Constructor Summary
Constructors Constructor Description TemplateOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends TemplateOptions>
Tas(Class<T> clazz)
TemplateOptions
authorizePublicKey(String publicKey)
authorize an rsa ssh key.TemplateOptions
blockOnComplete(boolean blockOnComplete)
As of version 1.1.0, we cannot kick off a script unless a node is in RUNNING state.TemplateOptions
blockOnPort(int port, int seconds)
When the node is started, wait until the following port is activeTemplateOptions
blockUntilRunning(boolean blockUntilRunning)
NoteTemplateOptions
clone()
void
copyTo(TemplateOptions to)
TemplateOptions
dontAuthorizePublicKey()
boolean
equals(Object o)
Set<String>
getGroups()
int[]
getInboundPorts()
Set<String>
getNetworks()
Set<String>
getNodeNames()
String
getPrivateKey()
String
getPublicKey()
Statement
getRunScript()
Set<String>
getTags()
Map<String,String>
getUserMetadata()
int
hashCode()
TemplateOptions
inboundPorts(int... ports)
Opens the set of ports to public access.TemplateOptions
installPrivateKey(String privateKey)
replaces the rsa ssh key used at login.TemplateOptions
nameTask(String name)
TemplateOptions
networks(Iterable<String> networks)
Assigns the created nodes to these networksTemplateOptions
networks(String... networks)
TemplateOptions
nodeNames(Iterable<String> nodeNames)
specifies names to be used for the created nodes.TemplateOptions
overrideAuthenticateSudo(boolean authenticateSudo)
TemplateOptions
overrideLoginCredentials(LoginCredentials overridingCredentials)
TemplateOptions
overrideLoginPassword(String password)
TemplateOptions
overrideLoginPrivateKey(String privateKey)
TemplateOptions
overrideLoginUser(String loginUser)
TemplateOptions
runAsRoot(boolean runAsRoot)
TemplateOptions
runScript(String script)
This script will be executed as the root user upon system startup.TemplateOptions
runScript(Statement script)
This script will be executed as the root user upon system startup.TemplateOptions
securityGroups(Iterable<String> securityGroups)
assigns the created nodes to these security groupsTemplateOptions
securityGroups(String... securityGroups)
boolean
shouldBlockUntilRunning()
com.google.common.base.MoreObjects.ToStringHelper
string()
TemplateOptions
tags(Iterable<String> tags)
assigns tags to the created nodesTemplateOptions
userMetadata(String key, String value)
TemplateOptions
userMetadata(Map<String,String> userMetadata)
TemplateOptions
wrapInInitScript(boolean wrapInInitScript)
default true-
Methods inherited from class org.jclouds.compute.options.RunScriptOptions
copyTo, getLoginPassword, getLoginPrivateKey, getLoginUser, getPort, getSeconds, getTaskName, hasLoginPassword, hasLoginPasswordOption, hasLoginPrivateKey, hasLoginPrivateKeyOption, overrideLoginPassword, overrideLoginPrivateKey, shouldAuthenticateSudo, shouldBlockOnComplete, shouldRunAsRoot, shouldWrapInInitScript, toString
-
-
-
-
Field Detail
-
NONE
public static final TemplateOptions NONE
-
script
protected Statement script
-
privateKey
protected String privateKey
-
publicKey
protected String publicKey
-
blockUntilRunning
protected boolean blockUntilRunning
-
-
Method Detail
-
clone
public TemplateOptions clone()
-
copyTo
public void copyTo(TemplateOptions to)
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classRunScriptOptions
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classRunScriptOptions
-
string
public com.google.common.base.MoreObjects.ToStringHelper string()
- Overrides:
string
in classRunScriptOptions
-
getInboundPorts
public int[] getInboundPorts()
-
getRunScript
public Statement getRunScript()
-
getPrivateKey
public String getPrivateKey()
-
getPublicKey
public String getPublicKey()
-
shouldBlockUntilRunning
public boolean shouldBlockUntilRunning()
- See Also:
blockUntilRunning(boolean)
-
as
public <T extends TemplateOptions> T as(Class<T> clazz)
-
runScript
public TemplateOptions runScript(String script)
This script will be executed as the root user upon system startup. This script gets a prologue, so no #!/bin/bash required, path set up, etc
-
runScript
public TemplateOptions runScript(Statement script)
This script will be executed as the root user upon system startup. This script gets a prologue, so no #!/bin/bash required, path set up, etc
-
installPrivateKey
public TemplateOptions installPrivateKey(String privateKey)
replaces the rsa ssh key used at login.
-
dontAuthorizePublicKey
public TemplateOptions dontAuthorizePublicKey()
-
authorizePublicKey
public TemplateOptions authorizePublicKey(String publicKey)
authorize an rsa ssh key.
-
tags
public TemplateOptions tags(Iterable<String> tags)
assigns tags to the created nodes
-
nodeNames
public TemplateOptions nodeNames(Iterable<String> nodeNames)
specifies names to be used for the created nodes. Note that this does not guarantee uniqueness - if there are already existing nodes with a name specified here, there will still be a new node created with the same name. Also, if more nodes are to be created than there are names, subsequent names will use the default naming strategy for that cloud.
-
securityGroups
public TemplateOptions securityGroups(Iterable<String> securityGroups)
assigns the created nodes to these security groups
-
securityGroups
public TemplateOptions securityGroups(String... securityGroups)
- See Also:
TemplateOptions#securityGroups(Iterable
)
-
networks
public TemplateOptions networks(Iterable<String> networks)
Assigns the created nodes to these networks
-
networks
public TemplateOptions networks(String... networks)
- See Also:
networks(Iterable)
-
inboundPorts
public TemplateOptions inboundPorts(int... ports)
Opens the set of ports to public access.
-
blockUntilRunning
public TemplateOptions blockUntilRunning(boolean blockUntilRunning)
Note
As of version 1.1.0, this option is incompatible withrunScript(Statement)
andRunScriptOptions.blockOnComplete(boolean)
, as all current implementations utilize ssh in order to execute scripts.- Parameters:
blockUntilRunning
- (default true) whether to block until the nodes in this template are inStatus#RUNNING
state
-
userMetadata
public TemplateOptions userMetadata(Map<String,String> userMetadata)
- Parameters:
userMetadata
- user-defined metadata to assign to this server
-
userMetadata
public TemplateOptions userMetadata(String key, String value)
- Parameters:
key
- key to place into the metadata mapvalue
- value to associate with that key
-
getUserMetadata
public Map<String,String> getUserMetadata()
- See Also:
userMetadata(Map)
-
blockOnPort
public TemplateOptions blockOnPort(int port, int seconds)
Description copied from class:RunScriptOptions
When the node is started, wait until the following port is active- Overrides:
blockOnPort
in classRunScriptOptions
-
nameTask
public TemplateOptions nameTask(String name)
- Overrides:
nameTask
in classRunScriptOptions
- Returns:
- What to call the task relating to this script; default
jclouds-script-timestamp
where timestamp is millis since epoch
-
runAsRoot
public TemplateOptions runAsRoot(boolean runAsRoot)
- Overrides:
runAsRoot
in classRunScriptOptions
-
wrapInInitScript
public TemplateOptions wrapInInitScript(boolean wrapInInitScript)
Description copied from class:RunScriptOptions
default true- Overrides:
wrapInInitScript
in classRunScriptOptions
- Parameters:
wrapInInitScript
- if the command is long-running, use this option to ensure it is wrapInInitScripted properly. (ex. have jclouds wrap it an init script, nohup, etc)- Returns:
-
blockOnComplete
public TemplateOptions blockOnComplete(boolean blockOnComplete)
Description copied from class:RunScriptOptions
As of version 1.1.0, we cannot kick off a script unless a node is in RUNNING state.- Overrides:
blockOnComplete
in classRunScriptOptions
- Parameters:
blockOnComplete
- (default true) false means kick off the script in the background, but don't wait for it to finish. (as of version 1.1.0, implemented as nohup)
-
overrideLoginCredentials
public TemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials)
- Overrides:
overrideLoginCredentials
in classRunScriptOptions
-
overrideLoginPassword
public TemplateOptions overrideLoginPassword(String password)
- Overrides:
overrideLoginPassword
in classRunScriptOptions
-
overrideLoginPrivateKey
public TemplateOptions overrideLoginPrivateKey(String privateKey)
- Overrides:
overrideLoginPrivateKey
in classRunScriptOptions
-
overrideLoginUser
public TemplateOptions overrideLoginUser(String loginUser)
- Overrides:
overrideLoginUser
in classRunScriptOptions
-
overrideAuthenticateSudo
public TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo)
- Overrides:
overrideAuthenticateSudo
in classRunScriptOptions
-
-