Quickstart
Three basic steps are required to create a workflow and execute it on Mistral:
- Create a workflow
- Run the workflow
In this quickstart guide, workflow creation are done with the openstack common command line tool. These steps can of course also be done with the OpenStack Dashboard.
1. Create a workflow
In order to create workflow on the CLI, you'll need access to the Mistral client tools, which are installed on lxplus.
Alternatively, you can install the client tools yourself or use a pre-configured Docker image on Windows or Mac OS
Once logged onto lxplus, obtain your OpenStack credentials, e.g. by sourcing your openrc file, and create a simple echo workflow
First get the echo workflow from our workflows repository
[lxplus]$ wget https://gitlab.cern.ch/cloud-infrastructure/mistral-workflows/raw/master/tests/echo.yaml
This file contains the following workflow that receives a parameter and after its execution, it gives you the same value as output
---
version: '2.0'
echo:
type: direct
description: 'Echo Workflow'
input:
- data
output:
data: <% $.data %>
tasks:
echo:
action: std.echo
input:
output: <% $.data %>
publish:
data: <% task(echo).result %>
You can validate the workflow definition by executing, it is useful as it checks its syntax, and all the transitions
[lxplus]$ openstack workflow validate echo.yaml
+-------+-------+
| Field | Value |
+-------+-------+
| Valid | True |
| Error | None |
+-------+-------+
You can create the workflow by running. If it gives you an error, you check it by validating it first
[lxplus]$ openstack workflow create echo.yaml
+--------------------------------------+------+--------------------------------------+--------+-------+---------+---------------------+------------+
| ID | Name | Project ID | Tags | Input | Scope | Created at | Updated at |
+--------------------------------------+------+--------------------------------------+--------+-------+---------+---------------------+------------+
| 65778b18-25a2-4709-87ce-f0d8d5bd50aa | echo | 01763ecd-a327-4d54-b045-3d46ca62f082 | <none> | data | private | 2018-02-15 12:19:35 | None |
+--------------------------------------+------+--------------------------------------+--------+-------+---------+---------------------+------------
2. Run the workflow
Still on lxplus, you can execute the echo workflow by running
[lxplus]$ openstack workflow execution create echo '{"data":"My First execution"}'
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| ID | 2a6e7388-1299-4e02-b76e-1c64e98e2317 |
| Workflow ID | 65778b18-25a2-4709-87ce-f0d8d5bd50aa |
| Workflow name | echo |
| Description | |
| Task Execution ID | <none> |
| State | RUNNING |
| State info | None |
| Created at | 2018-02-15 12:21:26 |
| Updated at | 2018-02-15 12:21:26 |
+-------------------+--------------------------------------+
Then you can see the status of the execution by typing:
[lxplus]$ openstack workflow execution show 2a6e7388-1299-4e02-b76e-1c64e98e2317
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| ID | 2a6e7388-1299-4e02-b76e-1c64e98e2317 |
| Workflow ID | 65778b18-25a2-4709-87ce-f0d8d5bd50aa |
| Workflow name | echo |
| Description | |
| Task Execution ID | <none> |
| State | SUCCESS |
| State info | None |
| Created at | 2018-02-15 12:21:26 |
| Updated at | 2018-02-15 12:21:27 |
+-------------------+--------------------------------------+
You can check the input and output of that execution like this.
[lxplus]$ openstack workflow execution input show 2a6e7388-1299-4e02-b76e-1c64e98e2317
{
"data": "My First execution"
}
[lxplus]$ openstack workflow execution output show 2a6e7388-1299-4e02-b76e-1c64e98e2317
{
"data": "My First execution"
}
Finally you can also see the actions executed and its input and output parameters
[lxplus]$ openstack action execution list
+--------------------------------------+----------------------------+-----------------+-----------------------+--------------------------------------+---------+----------+---------------------+---------------------+
| ID | Name | Workflow name | Task name | Task ID | State | Accepted | Created at | Updated at |
+--------------------------------------+----------------------------+-----------------+-----------------------+--------------------------------------+---------+----------+---------------------+---------------------+
| d73720d9-247c-40a7-84f0-1d1d4d5fec80 | std.echo | echo | echo | 808011d2-6135-481e-9800-be7e06dbc684 | SUCCESS | True | 2018-02-15 12:21:26 | 2018-02-15 12:21:26 |
+--------------------------------------+----------------------------+-----------------+-----------------------+--------------------------------------+---------+----------+---------------------+---------------------+
[lxplus]$ openstack action execution show d73720d9-247c-40a7-84f0-1d1d4d5fec80
+---------------+--------------------------------------+
| Field | Value |
+---------------+--------------------------------------+
| ID | d73720d9-247c-40a7-84f0-1d1d4d5fec80 |
| Name | std.echo |
| Workflow name | echo |
| Task name | echo |
| Task ID | 808011d2-6135-481e-9800-be7e06dbc684 |
| State | SUCCESS |
| State info | None |
| Accepted | True |
| Created at | 2018-02-15 12:21:26 |
| Updated at | 2018-02-15 12:21:26 |
+---------------+--------------------------------------+
[lxplus]$ openstack action execution input show d73720d9-247c-40a7-84f0-1d1d4d5fec80
{
"output": "My First execution"
}
[lxplus]$ openstack action execution output show d73720d9-247c-40a7-84f0-1d1d4d5fec80
{
"result": "My First execution"
}