Custom actions python API

Registered by Renat Akhmerov on 2016-03-03

Now:

Mistral allows to implement new actions and plug them into Mistral via a mechanism based on Stevedore. The issue is that a developer who is writing an action doesn't have a clearly scoped API that the action can use in its implementation.

The goal:

Create an API for action developers. More detailed on what should be in the API is at [1]. The idea is to have Actions API defined in a separate Mistral subproject called 'mistral-lib'. This project should define this API and its implementation. It may also contain utility classes and functions commonly by Mistral subprojects.

Motivation for using custom actions and not workflows:

* Some things are easier to do with python code.
* In some cases python code is more readable than a workflow
* When a code already exists, it’s better to reuse it in an action, than duplicate the logic to a workflow

Solution ideas/steps:

* Create a spec
  - Proposed Actions API
  - Module decomposition (e.g. what should be in mistral-lib and why)
* Make necessary changes in all components
* Move OpenStack actions to 'mistral-extra' and reimplement them with using Actions API.

Questions:

* What do we want to move into mistral-lib? Specifically, do context.py and other security modules need to be in mistral-lib? What about exceptions?

Links:

* https://blueprints.launchpad.net/mistral/+spec/mistral-custom-actions-api
* https://github.com/openstack/mistral-specs/blob/master/specs/newton/approved/mistral-custom-actions-api.rst
* https://review.openstack.org/#/c/411412/
* https://github.com/openstack/tripleo-common/blob/master/tripleo_common/actions/base.py

Notes:

* Questions to ask in order to understand if something needs to be in "mistral-lib"
** Does it need to be exposed to 3rd parties? Then Yes
** Is it a base class used in mistral, mistral client, mistral-lib? Then Yes

Decisions:

* Create a copy (maybe more optimized for external usage) of keystone_utils and move it into mistral-extra where our OpenStack action will reside
* mistral lib will contain code concerned with 3rd party action development
* mistral-extra will contain OpenStack specific integration + other generic actions like Ansible actions
* Update the spec (maybe after we have code)
* re-enable CI on mistral-extra (thrash)

Blueprint information

Status:
Started
Approver:
Renat Akhmerov
Priority:
High
Drafter:
Renat Akhmerov
Direction:
Approved
Assignee:
Renat Akhmerov
Definition:
New
Series goal:
Accepted for queens
Implementation:
Started
Milestone target:
None
Started by
Renat Akhmerov on 2016-07-05

Related branches

Sprints

Whiteboard

It seems odd right now when executing custom actions from the CLI that you would be required to provide auth twice, once to mistral when calling execute and having to provide an additional auth method inside the action itself. It would be beneficial to define some sort of security model for all actions (including custom) to ensure auth only needs to happen once.

rakhmerov: totally agree with that

Gerrit topic: https://review.openstack.org/#q,topic:bp/mistral-custom-actions-api,n,z

Addressed by: https://review.openstack.org/325769
    Custom actions API specification

Addressed by: https://review.openstack.org/340334
    Restructure mistral-extra repo

Addressed by: https://review.openstack.org/342644
    Initial project layout

Addressed by: https://review.openstack.org/345069
    Allow external access to cached clients

Addressed by: https://review.openstack.org/411412
    [WIP] Adds minimum common shared code for custom actions API

(?)

Work Items

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.