TriggerApplication

This step allows you to trigger any number of the same application based off of app variables or input data. If this step is set to have an ‘output_to’ setting, then it will automatically wait until all of it’s child triggered apps are completed. If output_to is not set, then it will simply trigger the childrenand then report success/failure on whether or not they were successful. If this step isn’t output_to anything, you can manually enable the waiting for child_failure with the wait_for_child_completion parameter

Added in version 1.0.0.

  • Friendly name: Trigger Application

  • Step class: base_steps_syncpack.steps.TriggerApplication.TriggerApplication

  • Step version: 1.3.3

  • Required parameters: value_as

Parameters

Name

Type

Required

Default

Description

foreach

json

no

–

Trigger multiple applications for each value in the list or dict Example: ${appvar.mappings}

input_iterator

json

no

False

If this is true, then trigger app will be executed for each item in the array of input data from the previous step. The data will be addedas an app_variable defined by the value_as parameter to the triggered app. This isnot compatible with the foreach parameter

key_as

string

no

–

If the ‘foreach’ field is a dict, this field specifies what app variable the key will be set as Example: snow_ci

value_as

json

yes

–

If the ‘foreach’ field is a dict, specifies what app variable the value will be set as. If the foreach field is a list, then the variable will be set with the elements of the list Example: em7_device_classes

trigger_app

string

no

–

The name of the application which should be triggered Example: em7_snow_device_export

app_vars

json

no

–

Allows a user to dynamically set a variable in a specific step of the triggered application Example: [{'name': 'em7_relative_url', 'value': '${stepfunc.determine_relative_url} ${em7_device_classes}]'

exit_on_child_failure

boolean

no

True

Only applies if this step is enabled to wait for triggered children completion. If this value is True, then if ny triggered app fails then this step will immediately be marked failure. If it is false, then this step will not fail if a child fails, but will still wait until all triggered apps are completed

wait_for_child_completion

boolean

no

False

Manual toggle of whether or not to wait for the triggered applications to complete

config_from_app_vars

boolean

no

False

Manual toggle of whether or not to use configuration from app_vars for the triggered applications

autofill_null_vars

boolean

no

False

Manual toggle of whether or not to autofill null appvars

Other inherited parameters

This step also accepts 1 optional parameter(s) inherited from Jinja2Template.

Every step also accepts the platform parameters common to all steps – see Platform parameters.

Dependencies

  • Inherits from: TriggerApplication -> Jinja2Template -> BaseStep -> Serializable

  • SyncPack modules: base_steps_syncpack.steps.Jinja2Template

  • External packages: celery, ipaascommon, ipaascore

Behaviour

Triggers any number of copies of the same application, via IpaasProcessManager.execute_application. Extends Jinja2Template, which is why template appears in its parameters — overridden to optional here.

The trigger strategy is chosen by get_class_for_trigger_type:

AppTrigger

One child application.

AppTriggerDict

One child per key/value pair, when foreach is a dict. key_as and value_as name the app variables the key and value are bound to.

AppTriggerInputIter

One child per item in the previous step’s input array, when input_iterator is set.

Whether it waits for the children is decided by two things: an output_to setting on the step, or wait_for_child_completion set explicitly. When waiting, it polls each triggered task’s Celery state until terminal, and raises StepFailedException on a child failure if exit_on_child_failure is set.

Outputs

None. The step does not call save_data_for_next_step, even when it waits for children — the children’s output does not come back through this step. To collect results, have the child applications write to the cache and read it with ReadFromCache.

Notes

  • foreach and input_iterator are mutually exclusive. Setting both is a configuration error, not a merge.

  • value_as is required. Without it there is no app variable to bind each value to, so the children all run with the same inputs.

  • Fire-and-forget is the default: with no output_to and wait_for_child_completion unset, the step reports success once the children are triggered, not once they succeed. A downstream step then runs while the children are still going.

  • exit_on_child_failure only applies while waiting. It has no effect in fire-and-forget mode.

  • autofill_null_vars fills null non-required app variables with {}, which can mask a genuinely missing value — prefer setting the variable.

API

class base_steps_syncpack.steps.TriggerApplication.TriggerApplication

Bases: Jinja2Template

Step will have the ability to trigger another application by pushing to the event queue

is_trigger_step()

Returns true if this step will be used to trigger another application (Overrides parent)

Returns:

wait_for_trigger_apps(status_list)

Reads from a list of currently running async responses and waits until each app is in a complete state. If any of the results indicate failure, then raise an exception at this step too.

Parameters:

status_list

Returns:

get_subapp_generator(content_manager)

This should be called by execute once we fully support triggering apps as a step (see comments at top of file) Generator which generates applications that should be triggered

Returns:

get_template_or_parameter_value(param_name, lookup_data={})

Returns value for param name from template or the param itself Template takes priority

Returns:

get_class_for_trigger_type()

Factory class which looks at the configuration set by the user, and returns the approrpiate class to handle the triggering (IE: trigger by dict, trigger by value, etc)

Returns: