Commit Graph

38 Commits

Author SHA1 Message Date
Renat Akhmerov 06a0f33476 Refactor Mistral with Action Providers
* This patch refactors Mistral with the action provider concept
  that is responsible for delivering actions to the system. So
  it takes all the burden of managing action definitions w/o
  having to spread that across multiple subsystems like Engine
  and API and w/o having to assume that action definitions are
  always stored in DB.
* Added LegacyActionProvider  that represents the old way of
  delivering action definitions to the system. It pretty much just
  analyses what entries are configured in the entry point
  "mistral.actions" in setup.cfg and build a collection of
  corresponding Python action classes in memory accessible by names.
* The module mistral/services/actions.py is now renamed to
  adhoc_actions.py because it's effectively responsible only for
  ad-hoc actions (those defined in YAML).
* Added the new entry point in setup.cfg "mistral.action.providers"
  to register action provider classes
* Added the module mistral/services/actions.py that will be a facade
  for action providers. Engine and other subsystems will need to
  work with it.
* Other small code changes.

Depends-On: I13033253d5098655a001135c8702d1b1d13e76d4
Depends-On: Ic9108c9293731b3576081c75f2786e1156ba0ccd
Change-Id: I8e826657acb12bbd705668180f7a3305e1e597e2
2020-09-24 11:10:33 +00:00
Renat Akhmerov 6dc0c05f04 Fix adhoc actions
* Method _create_action_execution() for AdHocActin didn't have
  the right signature. It was missing the argument "namespace" and
  failed under some conditions. This patch does some refactoring
  to preserve the target namespace during action init time. For
  regular python actions it's just taken from it's action definition
  object. For ad-hoc actions it is taken from its definition also
  but it has to do it separately because it extends the class
  PythonAction passing a base action definition into it as a parameter
  of the initializer (so that extracts the namespace of the base action).
  The benefit of preserving a namespace value during init time is that
  it becomes available for the entire instance life-span, not only for
  the method _create_action_execution().
* Style changes (blank lines, indentation, formatting).

Change-Id: I84d1cd0fb4a746197ad890276f654cd12455603e
2020-02-19 14:48:35 +07:00
ali 20c3408692 Add namespaces to Ad-Hoc actions
added namespace for the actions, actions can have the same name if they
 are not in the same namespace, when executing an action, if an action
 with that name is not found in the workflow namespace or given
 namespace mistral will look for that action in the default namespace.

  * action base can only be in the same namespace,or in the
    default namespace.
  * Namespaces are not part of the mistral DSL.
  * The default namespace is an empty string ''.
  * all actions will be in a namespace, if not specified, they will be
    under default namespace

Depends-On: I61acaed1658d291798e10229e81136259fcdb627
Change-Id: I07862e30adf28404ec70a473571a9213e53d8a08
Partially-Implements: blueprint create-and-run-workflows-within-a-namespace
Signed-off-by: ali <ali.abdelal@nokia.com>
2020-01-07 08:10:53 +00:00
Renat Akhmerov ac41f94d11 Add an ability to disable workflow text validation
* For the sake of the service performance, it may make sense to
  disable validation of the workflow language syntax if it is
  affordable for a particular use case. For example, if all
  workflows are auto-generated by a 3rd party system and tested
  thoroughly (either by running them with Mistral or at least
  validating them via the special Mistral endpoint) then we can
  safely disable validation of the language syntax when uploading
  workflow definitions. For production systems it makes a big
  difference if workflow texts are large (thousands of tasks).
  This patch adds the boolean parameter "skip_validation" for API
  requests like "POST /v2/workflows" to disable validation, if
  needed, and the new configuration property "validation_mode"
  to set a desired validation mode.
  The option is an enumeration and has the following valid values:
    1) "enabled" - enabled for all API requests unless it's
       explicitly disabled in the request itself
    2) "mandatory" - enabled for all API requests regardless
       of the flag in the request
    3) "disabled" - disabled for all API requrests regardless
       of the flag in the request
  "mandatory" is choosen as the default value for this new
  property to keep compatibility with the previous versions.
* Minor style changes.

Closes-Bug: #1844242

Change-Id: Ib509653d38254954f8449be3031457e5f636ccf2
2019-09-27 04:33:04 +00:00
Vitalii Solodilov 4bf03d8e7d Remove extra a specification validation
Currently when we get a specification using the instantiate_spec function,
we always validate their schema and semantics over and over again.
To prevent it we add new validate parameter to a Spec class.
The validate parameter must be True when we create a workflow, workbook
or action using a mistral-api. In all other cases, it must be False.

Change-Id: Ia450ea9635bc75c204fe031cfeeab154f1d03862
Closes-Bug: #1738769
Signed-off-by: Vitalii Solodilov <mcdkr@yandex.ru>
2018-07-30 11:55:35 +04:00
hardikj 834747b5d9 Add namespace support for workbooks
This patch brings namespace support to workbooks.
Namespace of the workbook is inherited by workflows.

Implements: blueprint mistral-namespace-for-actions-workbooks
Change-Id: I2c66b3961915f0f35a9c468eb6dd0c0c70995234
2018-07-26 17:13:58 +05:30
Istvan Imre f254c39257 Wrong handling of is_system flag at workbooks causes DB error with MySQL 5.7
If we leave is_system workbook attribute as undefined (Null) that causes
database insert error in MySQL 5.7, due to database constraints.
So let's use constant False as is_system attribute in workbook create.
It is OK, because there is no system workbook support in mistral yet.

Change-Id: Idabf9d04d105c2386b9b110f1bbab3e69502b8e0
Closes-Bug: #1733501
2017-11-24 14:47:25 +01:00
Michal Gershenzon cbee740de5 Create and run a workflow within a namespace
Allow adding many workflows with the same name.
The way this works is by adding the new workflows under another
namespace.

Notice that:
  1. Namespaces are not part of the mistral DSL.
  2. When executing a workflow, the namespace passes down to the
     subworkflow.
  3. When searching for the sub-workflow definition -
     If no workflow was found in the given namespace, than the defualt
     namespace will be used.
  4. The default namespace is an empty string.
  5. The namespace property or the workflow execution will be under
     params

Partially-Implements: blueprint create-and-run-workflows-within-a-namespace

Change-Id: Id248ec5906a0899d188675d002b45f6249d36d90
2017-08-01 13:51:05 +00:00
Renat Akhmerov 5c140a2fce Rename package 'workbook' to 'lang'
* The previous name of the package is not relevant anymore, it was
  chosen for reasons that don't make sense anymore. A name of the
  package should reflect that it's about the workflow language.

Change-Id: I7e05ba97abf0aa5db4e19d9d72b4ea0d52e328fb
2017-03-06 15:41:37 +07:00
Rajiv Kumar 285beb6f84 Removed unnecessary utf-8 encoding
Change-Id: Ic2ac9598e1098a9b75172af0cab1db31bc2cf9e7
2017-01-11 02:58:04 +00:00
Renat Akhmerov f2445acb28 Fix specification caching mechanism
* The problem was that cache instance was instantiated on different
  Mistral instances and invalidation didn't work properly (known
  problem for local cache implementations). The solution, first of
  all, is to cache specifications by workflow execution ids so that
  we get a consistent spec value during workflow execution lifetime.
  And secondly, if we need to build a specification based on
  workflow definition id we also need to use 'updated_at' as part of
  cache key so that if workflow definition has changed the cache is
  updated properly. Old cache entities would be kicked out of cache
  by LRU algorithm as the cache runs out of space.

Change-Id: If97b2e47d8adcbd7b5d5844b56e24eac1b1ae6c1
2016-08-09 20:16:09 +07:00
Renat Akhmerov 09c08864dc Invalidate workflow spec cache on workflow definition updates
* Workflow spec cache is updated on update of workbook and workflow
* Fixed scheduler docstring

Change-Id: I64042db4aa902166d2e80ea30adb7cbca1515c39
2016-08-02 11:47:28 +07:00
Renat Akhmerov d953cc82e6 Deleting redundant trust creation in workbook uploading mechanism
Change-Id: I9100a8415ad20b9f7572d73ba5a8f0a00a1e0143
Closes-Bug: #1555580
2016-03-10 18:03:54 +06:00
hardik 3234098624 Action definition updated, when workbook is created.
While creating workbook, action definition was not saved to
database. Due to which user was unable to see action definition

Change-Id: I69cf129d17d8db735770fc6231062cd61b3d4156
Closes-Bug: #1504429
2015-10-14 04:29:59 +00:00
Lingxian Kong e278571b1b Remove usage of expandtabs() in get_workflow_definition
There's no need to use that function for the purpose of calculating
indentation.

This patch is supplementary to the previouse patch[1], which I have
wrongly pressed workflow+1 button to have it merged. Please see my
comments there.

Fix the wrong indentation of workflow definition as well.

[1]: https://review.openstack.org/#/c/225559/

Change-Id: I8daac2f81989cff83abcb01096bdf84eae5d89eb
2015-09-28 17:12:30 +08:00
hardik 7a9b8f91b3 Workflow definition updated, when workbook is created
While creating workbook, workflow definition was not saved to
database. Due to which user was unable to see workflow definition

Change-Id: I0e3518be17198eadcc57a2eb8f15dc25266d338a
Closes-Bug: #1493343
2015-09-20 11:00:07 +05:30
Nikolay Mahotkin 9d5f197869 Implementing 'start_action' on engine side
* new engine method (symmetrically to start_workflow) -
    start_action;
  * possibility to run action without saving the result
    to the DB;
  * adjusted model_base: updated_at indeed can be None
    in set of cases;
  * improved engine.utils.validate_input for checking
    action_input (also adhoc action input); for this
    new util method for getting input dict from input
    string is introduced;
  * executor client can call rpc method synchronously
    for immediately returning result from action and
    without callback to engine;
  * fixed uploading actions from workbook;
  * improved action_handler;
  * improved inspect_utils for input validation needs.

TODO (next commit):
 - Implementing run action API side

Partially implements blueprint mistral-run-individual-action

Change-Id: I2fc1f3bb4382b72d6de7d7508c82d64e64ca656c
2015-06-25 09:47:04 +03:00
Limor Stotland e3120c3662 Fixing tags of wf as part of wb
*Add wf_spec.get_tags() to values in _create_or_update_workflows

Closes-Bug:#1436382

Change-Id: I1bdbc88181d55ec3707d9691f9a9eed73bbe3313
2015-04-15 12:27:36 +00:00
Renat Akhmerov b38328513a Deleting all v1 related stuff
* Old engine
* Endpoints
* Tests
* Fixed launch.cmd script
* Fixed the bug with incorrect RPC objects creation in tests

Change-Id: I8579d0878e8a295823124d3c3452f3c26151d43a
2015-04-07 20:07:24 +06:00
Renat Akhmerov bdefdc6a6f Refactoring task output: full redesign of DB models
* Created a Execution hierarcy mapped on a single table:
  - ActionExecution
  - WorkflowExecution
  - TaskExecution
* Created necessary associations within Execution hierarchy
* Created necessary methods for Execution objects on DB API
* Created Definition hierarchy mapped on separate tables:
  - Workbook
  - WorkflowDefinition
  - ActionDefinition
* Renamed attributes
  - 'wf_name' -> 'workflow_name'
  - 'wf_spec' -> 'spec'
* Fixed all unit tests

TODO:
* Complete renaming throughout the code
* Further refactoring of workflow engine

Change-Id: I0032bea573d9200025f9f7dd951e93cb6f1661bb
2015-03-03 16:50:55 +06:00
Renat Akhmerov 9fcbfbe2f9 Working on secure DB access (part 3)
* Moving method get_project_id() to services/security.py

Change-Id: Id4a166a754c1eda24280e7454530339b43243cb3
2015-01-22 16:37:30 +00:00
Renat Akhmerov 693227ffcf Working on secure DB access (part 1)
* Refactored DB models with new mixin class MistralSecureModelMixin
* Refactored services working with workflows, worbooks, actions
* Other minor changes

Change-Id: I9f2cb5c02670aa8c4c3dd06c4301f2e613f5c013
2015-01-22 16:35:26 +00:00
Renat Akhmerov b5140060a0 Renaming trusts.py to security.py and adding method add_security_info
Change-Id: Ia25afa6c24cbdba8eabfbd2adc0e7ca40a04b8b6
2014-11-27 15:53:32 +06:00
Renat Akhmerov de34c8a92b Refactoring workbooks service to be symmetric with other services
* Getting rid of dictionary as a parameter for create_workbook_v2() and
  update_workbook_v2(), instead a plain string (yaml definition) is used
* Fixed all the calls of these methods
* Fixed unit tests

Change-Id: I70dcbf844e2d10ab6619de7972f0253022c534cd
2014-11-27 15:53:16 +06:00
Renat Akhmerov 65d2330412 Modifying workbook service to infer name and tags from definition
Change-Id: I09cbcdad9939d6557ca5a4467e82be84d35a08de
2014-09-22 10:21:52 -07:00
Renat Akhmerov d8583b566d Fixing workbook service to create actions
Change-Id: I1983a2930b0e68313e038f2680db936c209403f8
2014-09-10 20:19:13 +07:00
Renat Akhmerov 8a9ae74d8e Switching to using 'with db_api.transaction()'
Change-Id: I80eba89e4c748e8c17c3f93f657f844c0e72e8a6
2014-09-08 17:27:11 +07:00
Jenkins f7088c12f4 Merge "Implement REST API v2.0" 2014-09-03 06:48:28 +00:00
Renat Akhmerov 6c56be9534 Fixing services/workbooks.py to use create_or_update_workflow()
Change-Id: I323221021ffa4fd66d487020aa47f02e02fb3f43
2014-09-01 11:18:08 +07:00
Kirill Izotov f25d099bcb Implement REST API v2.0
Change-Id: I6c46f3b691b0e721ca47b29f7a749338397d6dc6
Implements: blueprint mistral-rest-api-2.0
2014-09-01 11:17:53 +07:00
Nikolay Mahotkin 026ac2f207 Add service for delayed calls
* Delayed call mechanism works over DB

Partially implements: blueprint mistral-delayed-messaging

Change-Id: Ic7a517640673633e8cd2963650df91953dc958aa
2014-08-29 13:21:10 +04:00
Renat Akhmerov d5826ba6ed Improving services/workbooks
* Take care of workbook updates
* Unit tests

Change-Id: Iae9d13f335b8cca2409ad0731091edbbaa24a271
2014-08-27 17:24:40 +07:00
Renat Akhmerov 2b64cae308 Introducing 'workflow' as an individual entity
* Added Workflow DB model
* Removed 'workbook_name' parameter from Engine.start_workflow signature
* Fixed unit tests
* Fixed module trusts to create individual workbook entities when
 on workbook definition update
* Fixed API tests
* Switched v1 controllers to explicitly use DB API v1

Change-Id: I6a096e1c5d8082d3d1cdd47b575b85b28224d2a6
2014-08-27 17:24:02 +07:00
Angus Salkeld 9fa8cd669b Fix hacking rules H101 and E265
This is trivial, but easy to get out of the way.

Change-Id: Id261784e71c1b763c60090ffed92430d359f448b
2014-06-16 20:51:29 +10:00
Nikolay Mahotkin 7e01958c95 Rename 'events' to 'triggers'
* "events" are renamed to "triggers"
 * triggers moved out of workflow section

Implements: blueprint mistral-rename-event-to-trigger

Change-Id: I5b76e9c063a3ce9eec5d485bb5db5e22ac7981d4
2014-03-12 15:04:45 +04:00
Renat Akhmerov 44e38c97b7 Fixing and refactoring authentication
* Moved pecan configuration to oslo config
* Refactored functional base test
* Got rig of thread local related code in mistral/context.py
* Added new exception ApplicationContextNotFoundException
* Fixed example configuration file
* Made minor cosmetic changes (blank lines, naming)

Change-Id: I1899ce2562a34ebafa20c5735bdf4f0c80dd0175
2014-01-27 12:11:28 -05:00
Renat Akhmerov 593d277bc5 Adjusting all license headers in python files so they look the same
Change-Id: I9fa3b76916964f6675ac2967e80d6fc9b55ada54
2013-12-30 13:27:06 +07:00
Alexander Kuznetsov cafa9fed0e Added trust for workbook runs
Change-Id: Id2afa200858ce1cf9481883134d3c3d524f44cd9
2013-12-24 16:54:56 +04:00