deb-mistral/doc/source/developer/creating_custom_action.rst
Sharat Sharma d914e289dd Few changes in the doc
* Article "Architecture" is too small. It makes sense to add more
  information. - Added some more information

* I think we need to change "How to write an Action Plugin" to just
  "How to write a custom action". I think the word "plugin" here is
  not important from user perspective - Done

* I think we need to change "How to extend YAQL with a new function"
  to "How to write a custom YAQL function" and put it right next to
  "How to write a custom action". That would be more consistent.
  - Done

Change-Id: I9b43694072cb23271e33440741204da3e10b89ac
Partial-Implements: blueprint mistral-doc
2016-11-14 14:21:18 +05:30

1.1 KiB

How to write a Custom Action

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

class RunnerAction(base.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. Reinstall Mistral if it was installed in system (not in virtualenv).
  2. Run db-sync tool via either
$ tools/sync_db.sh --config-file <path-to-config>

or

$ 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