How to write a Custom Action in mistral

Bug #1833886 reported by Miles Yang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Confirmed
Medium
Renat Akhmerov

Bug Description

This bug tracker is for errors with the documentation, use the following as a template and remove or add fields as you see fit. Convert [ ] into [x] to check boxes:

- [ ] This doc is inaccurate in this way: ______
- [ ] This is a doc addition request.
- [x] I have a fix to the document that I can paste below including example: input and output.

example runner will raise this exception when using mistral run-action:

# mistral run-action example.runner '{"param": 1}'
{"result": "The action raised an exception [action_ex_id=None, action_cls='<class 'mistral.actions.action_factory.RunnerAction'>', attributes='{}', params='{'param': 1}']\n run() takes 1 positional argument but 2 were given"}

fix:
from mistral_lib import actions

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

    def run(self, context):
        # return your results here
        return {'status': 0}

If you have a troubleshooting or support issue, use the following resources:

 - Ask OpenStack: http://ask.openstack.org
 - The mailing list: http://lists.openstack.org
 - IRC: 'openstack' channel on Freenode

-----------------------------------
Release: 8.1.0.dev129 on 2018-07-23 14:14:40
SHA: f75e7198c61da0547ab6ab7e96c797ac5c6657da
Source: https://opendev.org/openstack/mistral/src/doc/source/contributor/creating_custom_action.rst
URL: https://docs.openstack.org/mistral/latest/contributor/creating_custom_action.html

Revision history for this message
Renat Akhmerov (rakhmerov) wrote :

Can you please explain in a normal human language what you would like to achieve? :)

It's hard to understand.

For example, what does this mean? "This bug tracker is for errors with the documentation, use the following as a template and remove or add fields as you see fit."

Revision history for this message
Miles Yang (yangyimincn) wrote :

sorry for my poor english.

inherited from mistral.actions.base.Action, current document exapmle is not right, with this example will not run example correctly. Custome Action must inherited mistral.actions.base.Action, But in example not inherited Action(method run(self) shound be run(self, context)).

Revision history for this message
Renat Akhmerov (rakhmerov) wrote :

Your english is perfectly fine! :) I just didn't understand the structure of your message. Now it is clear. Ok. We'll fix it.

Thanks!

Changed in mistral:
milestone: none → train-1
Changed in mistral:
milestone: train-1 → train-rc1
Changed in mistral:
milestone: train-rc1 → train-rc2
Changed in mistral:
milestone: train-rc2 → ussuri-1
assignee: nobody → Renat Akhmerov (rakhmerov)
importance: Undecided → Medium
status: New → Confirmed
Changed in mistral:
milestone: ussuri-1 → ussuri-2
Changed in mistral:
milestone: ussuri-2 → ussuri-3
Changed in mistral:
milestone: ussuri-3 → victoria-1
Changed in mistral:
milestone: victoria-1 → wallaby-1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.