Brooklyn

brooklyn.entity.chef
[Java] Class KnifeTaskFactory

java.lang.Object
  brooklyn.util.task.system.ProcessTaskStub
      brooklyn.util.task.system.internal.AbstractProcessTaskFactory
          brooklyn.util.task.system.internal.SystemProcessTaskFactory
              brooklyn.entity.chef.KnifeTaskFactory

public class KnifeTaskFactory
extends SystemProcessTaskFactory

A factory which acts like ProcessTaskFactory with special options for knife. Typical usage is to addKnifeParameters(String)s for the knife command to be run. You can also add(String...) commands as needed; these will run *before* knife, unless you addKnifeCommandHere().

This impl will use sensible defaults, including ConfigKeys on the context entity, for general knife config but not specific commands etc. It supports:

  • ChefConfig#KNIFE_EXECUTABLE#KNIFE_EXECUTABLE
  • ChefConfig#KNIFE_CONFIG_FILE#KNIFE_CONFIG_FILE

    (Other fields will typically be used by methods calling to this factory.)


    Field Summary
    protected java.lang.String knifeConfigFile

    protected java.lang.String knifeExecutable

    protected java.util.List knifeParameters

    protected java.lang.String knifeSetupCommands

    java.lang.String taskName

    protected java.lang.Boolean throwOnCommonKnifeErrors

     
    Fields inherited from class AbstractProcessTaskFactory
    dirty
     
    Fields inherited from class ProcessTaskStub
    commands, completionListeners, config, extraErrorMessage, machine, requireExitCodeZero, returnResultTransformation, returnType, runAsRoot, runAsScript, shellEnvironment, summary
     
    Constructor Summary
    KnifeTaskFactory(java.lang.String taskName)

     
    Method Summary
    KnifeTaskFactory addKnifeCommandToScript()

    Inserts the knife command at the current place in the list.

    protected java.lang.String buildKnifeCommand(int knifeCommandIndex)

    creates the command for running knife.

    protected Entity entity()

    callers should allow this to be null so task can be used outside of an entity

    protected java.lang.Object entityConfig(ConfigKey key)

    java.util.List getCommands()

    java.util.List getCompletionListeners()

    protected java.util.List initialKnifeParameters()

    allows a way for subclasses to build up parameters at the start

    protected void insertKnifeCompletionListenerIntoCompletionListenersList(java.util.List listeners)

    KnifeTaskFactory knifeAddParameters(java.lang.String word1, java.lang.String... words)

    KnifeTaskFactory knifeConfigFile(java.lang.String knifeConfigFile)

    protected java.lang.String knifeConfigFileOption()

    KnifeTaskFactory knifeExecutable(java.lang.String knifeExecutable)

    protected java.lang.String knifeExecutable()

    protected java.util.List knifeParameters()

    KnifeTaskFactory knifeSetupCommands(java.lang.String knifeSetupCommands)

    protected java.lang.String knifeSetupCommands()

    ProcessTaskWrapper newTask()

    KnifeTaskFactory notThrowingOnCommonKnifeErrors()

    KnifeTaskFactory requiringZeroAndReturningStdout()

    KnifeTaskFactory returning(ScriptReturnType type)

    KnifeTaskFactory returning(Function resultTransformation)

    KnifeTaskFactory returningIsExitCodeZero()

     
    Methods inherited from class SystemProcessTaskFactory
    machine, newExecWithLoggingHelpers, newTask
     
    Methods inherited from class AbstractProcessTaskFactory
    add, add, addCompletionListener, allowingNonZeroExitCode, configure, constructCustomizedTaskBuilder, environmentVariable, environmentVariables, finalize, machine, markDirty, requiringExitCodeZero, requiringExitCodeZero, requiringZeroAndReturningStdout, returning, returning, returningIsExitCodeZero, runAsCommand, runAsRoot, runAsScript, self, summary
     
    Methods inherited from class ProcessTaskStub
    getCommands, getCompletionListeners, getConfig, getMachine, getShellEnvironment, getSummary, toString
     

    Field Detail

    knifeConfigFile

    protected java.lang.String knifeConfigFile


    knifeExecutable

    protected java.lang.String knifeExecutable


    knifeParameters

    protected java.util.List knifeParameters


    knifeSetupCommands

    protected java.lang.String knifeSetupCommands


    taskName

    public final java.lang.String taskName


    throwOnCommonKnifeErrors

    protected java.lang.Boolean throwOnCommonKnifeErrors


     
    Constructor Detail

    KnifeTaskFactory

    public KnifeTaskFactory(java.lang.String taskName)


     
    Method Detail

    addKnifeCommandToScript

    public KnifeTaskFactory addKnifeCommandToScript()
    Inserts the knife command at the current place in the list. Can be run multiple times. The knife command added at the end of the list if this is not invoked (and it is the only command if nothing is add(String...)ed.


    buildKnifeCommand

    protected java.lang.String buildKnifeCommand(int knifeCommandIndex)
    creates the command for running knife. in some cases knife may be added multiple times, and in that case the parameter here tells which time it is being added, on a single run.


    entity

    }
    protected Entity entity()
    callers should allow this to be null so task can be used outside of an entity


    entityConfig

    protected java.lang.Object entityConfig(ConfigKey key)


    getCommands

    String setupCommands = knifeSetupCommands();
    public java.util.List getCommands()


    getCompletionListeners

    MutableList, Void>> result = MutableList.copyOf(super.getCompletionListeners());
    public java.util.List getCompletionListeners()


    initialKnifeParameters

    protected java.util.List initialKnifeParameters()
    allows a way for subclasses to build up parameters at the start


    insertKnifeCompletionListenerIntoCompletionListenersList

    protected void insertKnifeCompletionListenerIntoCompletionListenersList(java.util.List listeners)


    knifeAddParameters

    public KnifeTaskFactory knifeAddParameters(java.lang.String word1, java.lang.String... words)


    knifeConfigFile

    public KnifeTaskFactory knifeConfigFile(java.lang.String knifeConfigFile)


    knifeConfigFileOption

    String knifeConfigFileFromConfig = entityConfig(ChefConfig.KNIFE_CONFIG_FILE);
    protected java.lang.String knifeConfigFileOption()


    knifeExecutable

    public KnifeTaskFactory knifeExecutable(java.lang.String knifeExecutable)


    knifeExecutable

    protected java.lang.String knifeExecutable()


    knifeParameters

    protected java.util.List knifeParameters()


    knifeSetupCommands

    public KnifeTaskFactory knifeSetupCommands(java.lang.String knifeSetupCommands)


    knifeSetupCommands

    if (knifeSetupCommandsFromConfig!=null) return knifeSetupCommandsFromConfig;
    protected java.lang.String knifeSetupCommands()


    newTask

    }
    public ProcessTaskWrapper newTask()


    notThrowingOnCommonKnifeErrors

    public KnifeTaskFactory notThrowingOnCommonKnifeErrors()


    requiringZeroAndReturningStdout

    }
    public KnifeTaskFactory requiringZeroAndReturningStdout()


    returning

    public  KnifeTaskFactory returning(Function, RET2> resultTransformation) {
    public KnifeTaskFactory returning(ScriptReturnType type)


    returning

    public KnifeTaskFactory returningIsExitCodeZero() {
    public KnifeTaskFactory returning(Function resultTransformation)


    returningIsExitCodeZero

    public KnifeTaskFactory requiringZeroAndReturningStdout() {
    public KnifeTaskFactory returningIsExitCodeZero()


     

    Brooklyn Multi-Cloud Application Management Platform
    brooklyncentral.github.com. Apache License. © 2012.