How to write a Custom Action

How to write a Custom Action

  1. Write a class inherited from mistral.actions.base.Action

from mistral_lib import actions

class RunnerAction(actions.Action):
    def __init__(self, param):
        # store the incoming params
        self.param = param

    def run(self):
        # return your results here
        return {'status': 0}
  1. Publish the class in a namespace (in your setup.cfg)

[entry_points]
mistral.actions =
    example.runner = my.mistral_plugins.somefile:RunnerAction
  1. Install the Python package containing the action. If this was added to Mistral itself it will need to be reinstalled.

  2. Run the following command so Mistral discovers the new action

$ mistral-db-manage --config-file <path-to-config> populate
  1. Now you can call the action example.runner

my_workflow:
  tasks:
    my_action_task:
      action: example.runner
      input:
        param: avalue_to_pass_in
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.