Package org.jclouds.ec2.compute.options
Class EC2TemplateOptions
- java.lang.Object
-
- org.jclouds.compute.options.RunScriptOptions
-
- org.jclouds.compute.options.TemplateOptions
-
- org.jclouds.ec2.compute.options.EC2TemplateOptions
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
AWSEC2TemplateOptions
public class EC2TemplateOptions extends TemplateOptions implements Cloneable
Contains options supported in theComputeService#runNode
operation on the "ec2" provider.Usage
The recommended way to instantiate a EC2TemplateOptions object is to statically import EC2TemplateOptions.* and invoke a static creation method followed by an instance mutator (if needed):import static org.jclouds.aws.ec2.compute.options.EC2TemplateOptions.Builder.*; ComputeService client = // get connection templateBuilder.options(inboundPorts(22, 80, 8080, 443)); Set extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EC2TemplateOptions.Builder
-
Nested classes/interfaces inherited from class org.jclouds.compute.options.TemplateOptions
TemplateOptions.ImmutableTemplateOptions
-
Nested classes/interfaces inherited from class org.jclouds.compute.options.RunScriptOptions
RunScriptOptions.ImmutableRunScriptOptions
-
-
Field Summary
Fields Modifier and Type Field Description static EC2TemplateOptions
NONE
-
Fields inherited from class org.jclouds.compute.options.TemplateOptions
blockUntilRunning, inboundPorts, networks, nodeNames, privateKey, publicKey, script, securityGroups, tags, 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 EC2TemplateOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EC2TemplateOptions
authorizePublicKey(String publicKey)
authorize an rsa ssh key.EC2TemplateOptions
blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings)
EC2TemplateOptions
blockOnComplete(boolean blockOnComplete)
As of version 1.1.0, we cannot kick off a script unless a node is in RUNNING state.EC2TemplateOptions
blockOnPort(int port, int seconds)
When the node is started, wait until the following port is activeEC2TemplateOptions
blockUntilRunning(boolean blockUntilRunning)
NoteEC2TemplateOptions
clientToken(String clientToken)
EC2TemplateOptions
clone()
void
copyTo(TemplateOptions to)
EC2TemplateOptions
dontAuthorizePublicKey()
boolean
equals(Object o)
Set<BlockDeviceMapping>
getBlockDeviceMappings()
String
getClientToken()
See here for more information.Set<String>
getGroups()
String
getKeyPair()
int
getMaxCount()
byte[]
getUserData()
int
hashCode()
EC2TemplateOptions
inboundPorts(int... ports)
Opens the set of ports to public access.EC2TemplateOptions
installPrivateKey(String privateKey)
replaces the rsa ssh key used at login.EC2TemplateOptions
keyPair(String keyPair)
Specifies the keypair used to run instances withEC2TemplateOptions
mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, Integer sizeInGib, boolean deleteOnTermination)
EC2TemplateOptions
mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, Integer sizeInGib, boolean deleteOnTermination, String volumeType, Integer iops, boolean encrypted)
EC2TemplateOptions
mapEphemeralDeviceToDeviceName(String deviceName, String virtualName)
EC2TemplateOptions
mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination)
EC2TemplateOptions
mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination, String volumeType, Integer iops, boolean encrypted)
EC2TemplateOptions
maxCount(Integer maxCount)
EC2TemplateOptions
nameTask(String name)
EC2TemplateOptions
networks(Iterable<String> networks)
Assigns the created nodes to these networksEC2TemplateOptions
nodeNames(Iterable<String> nodeNames)
specifies names to be used for the created nodes.EC2TemplateOptions
noKeyPair()
Do not use a keypair on instancesEC2TemplateOptions
overrideAuthenticateSudo(boolean authenticateSudo)
EC2TemplateOptions
overrideLoginCredentials(LoginCredentials overridingCredentials)
EC2TemplateOptions
overrideLoginPassword(String password)
EC2TemplateOptions
overrideLoginPrivateKey(String privateKey)
EC2TemplateOptions
overrideLoginUser(String loginUser)
EC2TemplateOptions
runAsRoot(boolean runAsRoot)
EC2TemplateOptions
runScript(String script)
This script will be executed as the root user upon system startup.EC2TemplateOptions
runScript(Statement script)
This script will be executed as the root user upon system startup.EC2TemplateOptions
securityGroups(Iterable<String> groupNames)
Specifies the security groups to be used for nodes with this templateEC2TemplateOptions
securityGroups(String... groupNames)
boolean
shouldAutomaticallyCreateKeyPair()
com.google.common.base.MoreObjects.ToStringHelper
string()
EC2TemplateOptions
tags(Iterable<String> tags)
assigns tags to the created nodesEC2TemplateOptions
unmapDeviceNamed(String deviceName)
EC2TemplateOptions
userData(byte[] unencodedData)
Unencoded dataEC2TemplateOptions
userMetadata(String key, String value)
EC2TemplateOptions
userMetadata(Map<String,String> userMetadata)
EC2TemplateOptions
wrapInInitScript(boolean wrapInInitScript)
default true-
Methods inherited from class org.jclouds.compute.options.TemplateOptions
as, getInboundPorts, getNetworks, getNodeNames, getPrivateKey, getPublicKey, getRunScript, getTags, getUserMetadata, networks, shouldBlockUntilRunning
-
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 EC2TemplateOptions NONE
-
-
Method Detail
-
clone
public EC2TemplateOptions clone()
- Overrides:
clone
in classTemplateOptions
-
copyTo
public void copyTo(TemplateOptions to)
- Overrides:
copyTo
in classTemplateOptions
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classTemplateOptions
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classTemplateOptions
-
string
public com.google.common.base.MoreObjects.ToStringHelper string()
- Overrides:
string
in classTemplateOptions
-
securityGroups
public EC2TemplateOptions securityGroups(String... groupNames)
- Overrides:
securityGroups
in classTemplateOptions
- See Also:
EC2TemplateOptions#securityGroups(Iterable
)
-
securityGroups
public EC2TemplateOptions securityGroups(Iterable<String> groupNames)
Specifies the security groups to be used for nodes with this template- Overrides:
securityGroups
in classTemplateOptions
-
userData
public EC2TemplateOptions userData(byte[] unencodedData)
Unencoded data
-
keyPair
public EC2TemplateOptions keyPair(String keyPair)
Specifies the keypair used to run instances with
-
noKeyPair
public EC2TemplateOptions noKeyPair()
Do not use a keypair on instances
-
mapEBSSnapshotToDeviceName
public EC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, @Nullable Integer sizeInGib, boolean deleteOnTermination)
-
mapEBSSnapshotToDeviceName
public EC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, @Nullable Integer sizeInGib, boolean deleteOnTermination, @Nullable String volumeType, @Nullable Integer iops, boolean encrypted)
-
mapNewVolumeToDeviceName
public EC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination)
-
mapNewVolumeToDeviceName
public EC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination, @Nullable String volumeType, @Nullable Integer iops, boolean encrypted)
-
mapEphemeralDeviceToDeviceName
public EC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName)
-
unmapDeviceNamed
public EC2TemplateOptions unmapDeviceNamed(String deviceName)
-
blockDeviceMappings
public EC2TemplateOptions blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings)
-
maxCount
public EC2TemplateOptions maxCount(Integer maxCount)
-
clientToken
public EC2TemplateOptions clientToken(String clientToken)
-
blockOnPort
public EC2TemplateOptions blockOnPort(int port, int seconds)
When the node is started, wait until the following port is active- Overrides:
blockOnPort
in classTemplateOptions
-
inboundPorts
public EC2TemplateOptions inboundPorts(int... ports)
Opens the set of ports to public access.- Overrides:
inboundPorts
in classTemplateOptions
-
authorizePublicKey
public EC2TemplateOptions authorizePublicKey(String publicKey)
authorize an rsa ssh key.- Overrides:
authorizePublicKey
in classTemplateOptions
-
installPrivateKey
public EC2TemplateOptions installPrivateKey(String privateKey)
replaces the rsa ssh key used at login.- Overrides:
installPrivateKey
in classTemplateOptions
-
blockUntilRunning
public EC2TemplateOptions blockUntilRunning(boolean blockUntilRunning)
Note
As of version 1.1.0, this option is incompatible withTemplateOptions.runScript(Statement)
andRunScriptOptions.blockOnComplete(boolean)
, as all current implementations utilize ssh in order to execute scripts.- Overrides:
blockUntilRunning
in classTemplateOptions
- Parameters:
blockUntilRunning
- (default true) whether to block until the nodes in this template are inStatus#RUNNING
state
-
dontAuthorizePublicKey
public EC2TemplateOptions dontAuthorizePublicKey()
- Overrides:
dontAuthorizePublicKey
in classTemplateOptions
-
nameTask
public EC2TemplateOptions nameTask(String name)
- Overrides:
nameTask
in classTemplateOptions
- Returns:
- What to call the task relating to this script; default
jclouds-script-timestamp
where timestamp is millis since epoch
-
runAsRoot
public EC2TemplateOptions runAsRoot(boolean runAsRoot)
- Overrides:
runAsRoot
in classTemplateOptions
-
runScript
public EC2TemplateOptions 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- Overrides:
runScript
in classTemplateOptions
-
overrideLoginCredentials
public EC2TemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials)
- Overrides:
overrideLoginCredentials
in classTemplateOptions
-
overrideLoginPassword
public EC2TemplateOptions overrideLoginPassword(String password)
- Overrides:
overrideLoginPassword
in classTemplateOptions
-
overrideLoginPrivateKey
public EC2TemplateOptions overrideLoginPrivateKey(String privateKey)
- Overrides:
overrideLoginPrivateKey
in classTemplateOptions
-
overrideLoginUser
public EC2TemplateOptions overrideLoginUser(String loginUser)
- Overrides:
overrideLoginUser
in classTemplateOptions
-
overrideAuthenticateSudo
public EC2TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo)
- Overrides:
overrideAuthenticateSudo
in classTemplateOptions
-
userMetadata
public EC2TemplateOptions userMetadata(Map<String,String> userMetadata)
- Overrides:
userMetadata
in classTemplateOptions
- Parameters:
userMetadata
- user-defined metadata to assign to this server
-
userMetadata
public EC2TemplateOptions userMetadata(String key, String value)
- Overrides:
userMetadata
in classTemplateOptions
- Parameters:
key
- key to place into the metadata mapvalue
- value to associate with that key
-
nodeNames
public EC2TemplateOptions 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.- Overrides:
nodeNames
in classTemplateOptions
-
networks
public EC2TemplateOptions networks(Iterable<String> networks)
Assigns the created nodes to these networks- Overrides:
networks
in classTemplateOptions
-
runScript
public EC2TemplateOptions 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- Overrides:
runScript
in classTemplateOptions
-
tags
public EC2TemplateOptions tags(Iterable<String> tags)
assigns tags to the created nodes- Overrides:
tags
in classTemplateOptions
-
wrapInInitScript
public EC2TemplateOptions wrapInInitScript(boolean wrapInInitScript)
default true- Overrides:
wrapInInitScript
in classTemplateOptions
- 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 EC2TemplateOptions blockOnComplete(boolean blockOnComplete)
As of version 1.1.0, we cannot kick off a script unless a node is in RUNNING state.- Overrides:
blockOnComplete
in classTemplateOptions
- 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)
-
getGroups
public Set<String> getGroups()
- Overrides:
getGroups
in classTemplateOptions
- Returns:
- groupNames the user specified to run instances with, or zero length set to create an implicit group
-
getKeyPair
public String getKeyPair()
- Returns:
- keyPair to use when running the instance or null, to generate a keypair.
-
shouldAutomaticallyCreateKeyPair
public boolean shouldAutomaticallyCreateKeyPair()
- Returns:
- true (default) if we are supposed to use a keypair
-
getUserData
public byte[] getUserData()
- Returns:
- unencoded user data.
-
getBlockDeviceMappings
public Set<BlockDeviceMapping> getBlockDeviceMappings()
- Returns:
- BlockDeviceMapping to use when running the instance or null.
-
getMaxCount
public int getMaxCount()
- Returns:
- the maximum number of instances to create
-
-