Fixing indentation in 'create action' tutorial
Partially implements blueprint mistral-documentation Change-Id: I50fa230684b4ef64f7f6ae81d342d670eb5bf695
This commit is contained in:
parent
f42b7f5f5e
commit
25a1242c32
@ -1,48 +1,53 @@
|
|||||||
|
=============================
|
||||||
How to write an Action Plugin
|
How to write an Action Plugin
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
1. Write a class inherited from mistral.actions.base.Action
|
1. Write a class inherited from mistral.actions.base.Action
|
||||||
::
|
|
||||||
|
|
||||||
from mistral.actions import base
|
.. code-block:: python
|
||||||
|
|
||||||
class RunnerAction(base.Action):
|
from mistral.actions import base
|
||||||
def __init__(self, param):
|
|
||||||
# store the incomming params
|
|
||||||
self.param = param
|
|
||||||
|
|
||||||
def run(self):
|
class RunnerAction(base.Action):
|
||||||
# return your results here
|
def __init__(self, param):
|
||||||
return {'status': 0}
|
# store the incomming params
|
||||||
|
self.param = param
|
||||||
|
|
||||||
2. Publish the class in a namespace
|
def run(self):
|
||||||
(in your setup.cfg)
|
# return your results here
|
||||||
|
return {'status': 0}
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
[entry_points]
|
2. Publish the class in a namespace (in your ``setup.cfg``)
|
||||||
mistral.actions =
|
|
||||||
example.runner = my.mistral_plugins.somefile:RunnerAction
|
|
||||||
|
.. code-block:: ini
|
||||||
|
|
||||||
|
[entry_points]
|
||||||
|
mistral.actions =
|
||||||
|
example.runner = my.mistral_plugins.somefile:RunnerAction
|
||||||
|
|
||||||
3. Reinstall Mistral if it was installed in system (not in virtualenv).
|
3. Reinstall Mistral if it was installed in system (not in virtualenv).
|
||||||
4. Run Db-sync tool via either::
|
|
||||||
|
|
||||||
*tools/sync_db.sh --config-file <path-to-config>*
|
4. Run db-sync tool via either
|
||||||
|
|
||||||
or::
|
.. code-block:: console
|
||||||
|
|
||||||
*mistral-db-manage --config-file <path-to-config> populate*
|
$ tools/sync_db.sh --config-file <path-to-config>
|
||||||
|
|
||||||
5. Use your plugin
|
or
|
||||||
|
|
||||||
* Now you can call the action "example.runner"
|
.. code-block:: console
|
||||||
|
|
||||||
::
|
$ mistral-db-manage --config-file <path-to-config> populate
|
||||||
|
|
||||||
Workflow:
|
5. Now you can call the action ``example.runner``
|
||||||
tasks:
|
|
||||||
myaction:
|
|
||||||
action: example.runner
|
|
||||||
parameters:
|
|
||||||
param: avalue_to_pass_in
|
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
my_workflow:
|
||||||
|
tasks:
|
||||||
|
my_action_task:
|
||||||
|
action: example.runner
|
||||||
|
input:
|
||||||
|
param: avalue_to_pass_in
|
||||||
|
Loading…
Reference in New Issue
Block a user