org.jclouds.compute.options
Class TemplateOptions

java.lang.Object
  extended by org.jclouds.compute.options.RunScriptOptions
      extended by org.jclouds.compute.options.TemplateOptions
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
EC2TemplateOptions, GoGridTemplateOptions, SoftLayerTemplateOptions, TemplateOptions.ImmutableTemplateOptions, TerremarkVCloudTemplateOptions, VCloudTemplateOptions

public class TemplateOptions
extends RunScriptOptions
implements Cloneable

Contains options supported in the ComputeService#runNodesWithTag operation.

Usage

The recommended way to instantiate a TemplateOptions object is to statically import TemplateOptions.* and invoke a static creation method followed by an instance mutator (if needed):

import static org.jclouds.compute.options.TemplateOptions.Builder.*;

ComputeService client = // get connection templateBuilder.options(inboundPorts(22, 80, 8080, 443)); Set set = client.runNodesWithTag(tag, 2, templateBuilder.build());

Author:
Adrian Cole

Nested Class Summary
static class TemplateOptions.Builder
           
static class TemplateOptions.ImmutableTemplateOptions
           
 
Nested classes/interfaces inherited from class org.jclouds.compute.options.RunScriptOptions
RunScriptOptions.ImmutableRunScriptOptions
 
Field Summary
protected  boolean blockUntilRunning
           
protected  int[] inboundPorts
           
static TemplateOptions NONE
           
protected  String privateKey
           
protected  String publicKey
           
protected  Statement script
           
protected  Set<String> tags
           
protected  Map<String,String> userMetadata
           
 
Fields inherited from class org.jclouds.compute.options.RunScriptOptions
blockOnComplete, overridingCredentials, port, runAsRoot, seconds, taskName, wrapInInitScript
 
Constructor Summary
TemplateOptions()
           
 
Method Summary
<T extends TemplateOptions>
T
as(Class<T> clazz)
           
 TemplateOptions authorizePublicKey(Payload publicKey)
          Deprecated. 
 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 active
 TemplateOptions blockUntilRunning(boolean blockUntilRunning)
          Note
 TemplateOptions clone()
           
 void copyTo(TemplateOptions to)
           
 TemplateOptions dontAuthorizePublicKey()
           
 boolean equals(Object obj)
           
 int[] getInboundPorts()
           
 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(Payload privateKey)
          Deprecated. 
 TemplateOptions installPrivateKey(String privateKey)
          replaces the rsa ssh key used at login.
 TemplateOptions nameTask(String name)
           
 TemplateOptions overrideCredentialsWith(Credentials overridingCredentials)
           
 TemplateOptions overrideLoginCredentialWith(String loginCredential)
           
 TemplateOptions overrideLoginUserWith(String loginUser)
           
 TemplateOptions runAsRoot(boolean runAsRoot)
           
 TemplateOptions runScript(byte[] script)
          Deprecated. 
 TemplateOptions runScript(Payload script)
           
 TemplateOptions runScript(Statement script)
          This script will be executed as the root user upon system startup.
 boolean shouldBlockUntilRunning()
           
 TemplateOptions tags(Iterable<String> tags)
          assigns tags to the created nodes
 String toString()
           
 TemplateOptions userMetadata(Map<String,String> userMetadata)
           
 TemplateOptions userMetadata(String key, String value)
           
 TemplateOptions wrapInInitScript(boolean wrapInInitScript)
          default true

 
Methods inherited from class org.jclouds.compute.options.RunScriptOptions
getOverridingCredentials, getPort, getSeconds, getTaskName, shouldBlockOnComplete, shouldRunAsRoot, shouldWrapInInitScript
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final TemplateOptions NONE

inboundPorts

protected int[] inboundPorts

script

protected Statement script

tags

protected Set<String> tags

privateKey

protected String privateKey

publicKey

protected String publicKey

blockUntilRunning

protected boolean blockUntilRunning

userMetadata

protected Map<String,String> userMetadata
Constructor Detail

TemplateOptions

public TemplateOptions()
Method Detail

clone

public TemplateOptions clone()
Overrides:
clone in class Object

copyTo

public void copyTo(TemplateOptions to)

getInboundPorts

public int[] getInboundPorts()

getRunScript

public Statement getRunScript()

getTags

public Set<String> getTags()

getPrivateKey

public String getPrivateKey()

getPublicKey

public String getPublicKey()

shouldBlockUntilRunning

public boolean shouldBlockUntilRunning()
See Also:
TemplateOptions.ImmutableTemplateOptions.blockUntilRunning(boolean)

as

public <T extends TemplateOptions> T as(Class<T> clazz)

runScript

@Deprecated
public TemplateOptions runScript(byte[] script)
Deprecated. 

please use alternative that uses the Statement object

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

runScript

public TemplateOptions runScript(Payload script)
See Also:
TemplateOptions.ImmutableTemplateOptions.runScript(Statement), Payloads

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.


installPrivateKey

@Deprecated
public TemplateOptions installPrivateKey(Payload privateKey)
Deprecated. 

replaces the rsa ssh key used at login.

please use alternative that uses String

See Also:
Payloads

dontAuthorizePublicKey

public TemplateOptions dontAuthorizePublicKey()

authorizePublicKey

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


authorizePublicKey

@Deprecated
public TemplateOptions authorizePublicKey(Payload publicKey)
Deprecated. 

authorize an rsa ssh key.

please use alternative that uses String

See Also:
Payloads

tags

public TemplateOptions tags(Iterable<String> tags)
assigns tags to the created nodes


inboundPorts

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


toString

public String toString()
Overrides:
toString in class RunScriptOptions

blockUntilRunning

public TemplateOptions 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.

Parameters:
blockUntilRunning - (default true) whether to block until the nodes in this template are in NodeState.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 map
value - value to associate with that key

getUserMetadata

public Map<String,String> getUserMetadata()
See Also:
userMetadata(Map)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

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

nameTask

public TemplateOptions nameTask(String name)
Overrides:
nameTask in class RunScriptOptions
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 class RunScriptOptions

overrideCredentialsWith

public TemplateOptions overrideCredentialsWith(Credentials overridingCredentials)
Overrides:
overrideCredentialsWith in class RunScriptOptions

overrideLoginUserWith

public TemplateOptions overrideLoginUserWith(String loginUser)
Overrides:
overrideLoginUserWith in class RunScriptOptions

overrideLoginCredentialWith

public TemplateOptions overrideLoginCredentialWith(String loginCredential)
Overrides:
overrideLoginCredentialWith in class RunScriptOptions

wrapInInitScript

public TemplateOptions wrapInInitScript(boolean wrapInInitScript)
Description copied from class: RunScriptOptions
default true

Overrides:
wrapInInitScript in class RunScriptOptions
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 class RunScriptOptions
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)


Copyright © 2009-2011 jclouds. All Rights Reserved.