Skip to content

Quickstart

Quickstart

Three basic steps are required to create a workflow and execute it on Mistral:

  1. Create a workflow
  2. 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. We recommend to use lxplus-cloud, a subset of 'lxplus', which has the tools installed.

Alternatively, you can install the client tools yourself or use a pre-configured Docker image.

Once logged onto lxplus-cloud, 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-cloud]$ 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-cloud]$ 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-cloud]$ 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-cloud, you can execute the echo workflow by running

[lxplus-cloud]$ 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                  |
+-------------------+--------------------------------------+

As you can see the input data is passed in a JSON dictionary.

Then you can see the status of the execution by typing:

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-cloud]$ openstack workflow execution input show 2a6e7388-1299-4e02-b76e-1c64e98e2317
{
    "data": "My First execution"
}
[lxplus-cloud]$ (venv) ✔ user@notepad:~/gitlab/cloud-infrastructure/mistral-workflows/tests [master|✔]> 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-cloud]$ 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-cloud]$ 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-cloud]$ openstack action execution input show d73720d9-247c-40a7-84f0-1d1d4d5fec80
{
    "output": "My First execution"
}
[lxplus-cloud]$ openstack action execution output show d73720d9-247c-40a7-84f0-1d1d4d5fec80
{
    "result": "My First execution"
}