org.jclouds.ec2.compute.options
Class EC2TemplateOptions

java.lang.Object
  extended by org.jclouds.compute.options.RunScriptOptions
      extended by org.jclouds.compute.options.TemplateOptions
          extended by 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 the ComputeService#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 set = client.createNodesInGroup(tag, 2, templateBuilder.build());

Author:
Adrian Cole

Nested Class Summary
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
static EC2TemplateOptions NONE
           
 
Fields inherited from class org.jclouds.compute.options.TemplateOptions
blockUntilRunning, inboundPorts, privateKey, publicKey, script, tags, userMetadata
 
Fields inherited from class org.jclouds.compute.options.RunScriptOptions
authenticateSudo, blockOnComplete, loginPassword, loginPrivateKey, loginUser, port, runAsRoot, seconds, taskName, wrapInInitScript
 
Constructor Summary
EC2TemplateOptions()
           
 
Method Summary
 EC2TemplateOptions authorizePublicKey(String publicKey)
          authorize an rsa ssh key.
 EC2TemplateOptions blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings)
           
 EC2TemplateOptions blockOnPort(int port, int seconds)
          When the node is started, wait until the following port is active
 EC2TemplateOptions blockUntilRunning(boolean blockUntilRunning)
          Note
 EC2TemplateOptions clone()
           
 void copyTo(TemplateOptions to)
           
 EC2TemplateOptions dontAuthorizePublicKey()
          
 boolean equals(Object obj)
           
 Set<BlockDeviceMapping> getBlockDeviceMappings()
           
 Set<String> getGroups()
           
 String getKeyPair()
           
 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 with
 EC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, Integer sizeInGib, boolean deleteOnTermination)
           
 EC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName)
           
 EC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination)
           
 EC2TemplateOptions nameTask(String name)
          
 EC2TemplateOptions noKeyPair()
          Do not use a keypair on instances
 EC2TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo)
          
 EC2TemplateOptions overrideCredentialsWith(Credentials overridingCredentials)
          Deprecated. 
 EC2TemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials)
          
 EC2TemplateOptions overrideLoginCredentialWith(String loginCredential)
          Deprecated. 
 EC2TemplateOptions overrideLoginPassword(String password)
          
 EC2TemplateOptions overrideLoginPrivateKey(String privateKey)
          
 EC2TemplateOptions overrideLoginUser(String loginUser)
          
 EC2TemplateOptions overrideLoginUserWith(String loginUser)
          Deprecated. 
 EC2TemplateOptions runAsRoot(boolean runAsRoot)
          
 EC2TemplateOptions runScript(Payload script)
          Deprecated. 
 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 template
 EC2TemplateOptions securityGroups(String... groupNames)
           
 boolean shouldAutomaticallyCreateKeyPair()
           
 String toString()
           
 EC2TemplateOptions unmapDeviceNamed(String deviceName)
           
 EC2TemplateOptions userData(byte[] unencodedData)
          Unencoded data
 EC2TemplateOptions userMetadata(Map<String,String> userMetadata)
          
 EC2TemplateOptions userMetadata(String key, String value)
          
 
Methods inherited from class org.jclouds.compute.options.TemplateOptions
as, blockOnComplete, getInboundPorts, getPrivateKey, getPublicKey, getRunScript, getTags, getUserMetadata, runScript, shouldBlockUntilRunning, tags, wrapInInitScript
 
Methods inherited from class org.jclouds.compute.options.RunScriptOptions
getLoginPassword, getLoginPrivateKey, getLoginUser, getOverridingCredentials, getPort, getSeconds, getTaskName, hasLoginPassword, hasLoginPasswordOption, hasLoginPrivateKey, hasLoginPrivateKeyOption, shouldAuthenticateSudo, shouldBlockOnComplete, shouldRunAsRoot, shouldWrapInInitScript
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final EC2TemplateOptions NONE
Constructor Detail

EC2TemplateOptions

public EC2TemplateOptions()
Method Detail

clone

public EC2TemplateOptions clone()
Overrides:
clone in class TemplateOptions

copyTo

public void copyTo(TemplateOptions to)
Overrides:
copyTo in class TemplateOptions

securityGroups

public EC2TemplateOptions securityGroups(String... groupNames)
See Also:
EC2TemplateOptions#securityGroups(Iterable)

securityGroups

public EC2TemplateOptions securityGroups(Iterable<String> groupNames)
Specifies the security groups to be used for nodes with this template


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)

mapNewVolumeToDeviceName

public EC2TemplateOptions mapNewVolumeToDeviceName(String deviceName,
                                                   int sizeInGib,
                                                   boolean deleteOnTermination)

mapEphemeralDeviceToDeviceName

public EC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName,
                                                         String virtualName)

unmapDeviceNamed

public EC2TemplateOptions unmapDeviceNamed(String deviceName)

blockDeviceMappings

public EC2TemplateOptions blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings)

blockOnPort

public EC2TemplateOptions blockOnPort(int port,
                                      int seconds)
When the node is started, wait until the following port is active

Overrides:
blockOnPort in class TemplateOptions

inboundPorts

public EC2TemplateOptions inboundPorts(int... ports)
Opens the set of ports to public access.

Overrides:
inboundPorts in class TemplateOptions

authorizePublicKey

public EC2TemplateOptions authorizePublicKey(String publicKey)
authorize an rsa ssh key.

Overrides:
authorizePublicKey in class TemplateOptions

installPrivateKey

public EC2TemplateOptions installPrivateKey(String privateKey)
replaces the rsa ssh key used at login.

Overrides:
installPrivateKey in class TemplateOptions

runScript

@Deprecated
public EC2TemplateOptions runScript(Payload script)
Deprecated. 

to be removed in jclouds 1.4.0

Overrides:
runScript in class TemplateOptions
See Also:
TemplateOptions.ImmutableTemplateOptions.runScript(Statement), Payloads

blockUntilRunning

public EC2TemplateOptions blockUntilRunning(boolean blockUntilRunning)

Note

As of version 1.1.0, this option is incompatible with TemplateOptions.ImmutableTemplateOptions.runScript(Statement) and RunScriptOptions.blockOnComplete(boolean), as all current implementations utilize ssh in order to execute scripts.

Overrides:
blockUntilRunning in class TemplateOptions
Parameters:
blockUntilRunning - (default true) whether to block until the nodes in this template are in NodeState.RUNNING state

dontAuthorizePublicKey

public EC2TemplateOptions dontAuthorizePublicKey()

Overrides:
dontAuthorizePublicKey in class TemplateOptions

nameTask

public EC2TemplateOptions nameTask(String name)

Overrides:
nameTask in class TemplateOptions
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 class TemplateOptions

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 class TemplateOptions

overrideCredentialsWith

@Deprecated
public EC2TemplateOptions overrideCredentialsWith(Credentials overridingCredentials)
Deprecated. 

to be removed in jclouds 1.4.0

Overrides:
overrideCredentialsWith in class TemplateOptions
See Also:
RunScriptOptions.overrideLoginCredentials(org.jclouds.domain.LoginCredentials)

overrideLoginUserWith

@Deprecated
public EC2TemplateOptions overrideLoginUserWith(String loginUser)
Deprecated. 

to be removed in jclouds 1.4.0

Overrides:
overrideLoginUserWith in class TemplateOptions
See Also:
RunScriptOptions.overrideLoginCredentials(org.jclouds.domain.LoginCredentials)

overrideLoginCredentialWith

@Deprecated
public EC2TemplateOptions overrideLoginCredentialWith(String loginCredential)
Deprecated. 

to be removed in jclouds 1.4.0

Overrides:
overrideLoginCredentialWith in class TemplateOptions
See Also:
RunScriptOptions.overrideLoginCredentials(org.jclouds.domain.LoginCredentials)

overrideLoginCredentials

public EC2TemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials)

Overrides:
overrideLoginCredentials in class TemplateOptions

overrideLoginPassword

public EC2TemplateOptions overrideLoginPassword(String password)

Overrides:
overrideLoginPassword in class TemplateOptions

overrideLoginPrivateKey

public EC2TemplateOptions overrideLoginPrivateKey(String privateKey)

Overrides:
overrideLoginPrivateKey in class TemplateOptions

overrideLoginUser

public EC2TemplateOptions overrideLoginUser(String loginUser)

Overrides:
overrideLoginUser in class TemplateOptions

overrideAuthenticateSudo

public EC2TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo)

Overrides:
overrideAuthenticateSudo in class TemplateOptions

userMetadata

public EC2TemplateOptions userMetadata(Map<String,String> userMetadata)

Overrides:
userMetadata in class TemplateOptions
Parameters:
userMetadata - user-defined metadata to assign to this server

userMetadata

public EC2TemplateOptions userMetadata(String key,
                                       String value)

Overrides:
userMetadata in class TemplateOptions
Parameters:
key - key to place into the metadata map
value - value to associate with that key

getGroups

public Set<String> getGroups()
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.

hashCode

public int hashCode()
Overrides:
hashCode in class TemplateOptions

equals

public boolean equals(Object obj)
Overrides:
equals in class TemplateOptions

toString

public String toString()
Overrides:
toString in class TemplateOptions


Copyright © 2009-2012 jclouds. All Rights Reserved.