1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
Quick Start
===========
Prerequisites
-------------
Before you start following this guide, make sure you have completed these
three prerequisites.
Install and run Mistral
~~~~~~~~~~~~~~~~~~~~~~~
Go through the installation manual:
:doc:`Mistral Installation Guide <install/index>`
Mistral Client Command Guide
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To use mistralclient, please refer to
:doc:`Mistral Client / CLI Guide </user/cli/index>`
Export Keystone credentials
~~~~~~~~~~~~~~~~~~~~~~~~~~~
To use the OpenStack command line tools you should specify environment
variables with the configuration details for your OpenStack installation. The
following example assumes that the Identity service is at ``127.0.0.1:5000``,
with a user ``admin`` in the ``admin`` tenant whose password is ``password``:
.. code-block:: bash
$ export OS_AUTH_URL=http://127.0.0.1:5000/v2.0/
$ export OS_TENANT_NAME=admin
$ export OS_USERNAME=admin
$ export OS_PASSWORD=password
Write a workflow
----------------
For example, we have the following workflow.
::
---
version: "2.0"
my_workflow:
type: direct
input:
- names
tasks:
task1:
with-items: name in <% $.names %>
action: std.echo output=<% $.name %>
on-success: task2
task2:
action: std.echo output="Done"
This simple workflow iterates through a list of names in ``task1`` (using
`with-items`), stores them as a task result (using the `std.echo` action) and
then stores the word "Done" as a result of the second task (`task2`).
To learn more about the Mistral Workflows and what you can do, read the
:doc:`Mistral Workflow Language specification </user/wf_lang_v2>`
Upload the workflow
-------------------
Use the *Mistral CLI* to create the workflow::
$ mistral workflow-create <workflow.yaml>
The output should look similar to this::
+------------------------------------+-------------+-----------+--------+-------+---------------------+------------+
|ID | Name | Namespace | Tags | Input | Created at | Updated at |
+------------------------------------+-------------+-----------+--------+-------+---------------------+------------+
|9b719d62-2ced-47d3-b500-73261bb0b2ad| my_workflow | | <none> | names | 2015-08-13 08:44:49 | None |
+------------------------------------+-------------+-----------+--------+-------+---------------------+------------+
Run the workflow and check the result
-------------------------------------
Use the *Mistral CLI* to start the new workflow, passing in a list of names
as JSON::
$ mistral execution-create my_workflow '{"names": ["John", "Mistral", "Ivan", "Crystal"]}'
Make sure the output is like the following::
+--------------------+--------------------------------------+
| Field | Value |
+--------------------+--------------------------------------+
| ID | 49213eb5-196c-421f-b436-775849b55040 |
| Workflow ID | 9b719d62-2ced-47d3-b500-73261bb0b2ad |
| Workflow name | my_workflow |
| Workflow namespace | |
| Description | |
| Task Execution ID | <none> |
| Root Execution ID | <none> |
| State | RUNNING |
| State info | None |
| Created at | 2017-03-06 11:24:10 |
| Updated at | 2017-03-06 11:24:10 |
+--------------------+--------------------------------------+
After a moment, check the status of the workflow execution (replace the
example execution id with the ID output above)::
$ mistral execution-get 49213eb5-196c-421f-b436-775849b55040
+--------------------+--------------------------------------+
| Field | Value |
+--------------------+--------------------------------------+
| ID | 49213eb5-196c-421f-b436-775849b55040 |
| Workflow ID | 9b719d62-2ced-47d3-b500-73261bb0b2ad |
| Workflow name | my_workflow |
| Workflow namespace | |
| Description | |
| Task Execution ID | <none> |
| Root Execution ID | <none> |
| State | SUCCESS |
| State info | None |
| Created at | 2017-03-06 11:24:10 |
| Updated at | 2017-03-06 11:24:20 |
+--------------------+--------------------------------------+
The status of each **task** also can be checked::
$ mistral task-list 49213eb5-196c-421f-b436-775849b55040
+--------------------------------------+-------+---------------+--------------------+--------------------------------------+---------+------------+---------------------+---------------------+
| ID | Name | Workflow name | Workflow namespace | Execution ID | State | State info | Created at | Updated at |
+--------------------------------------+-------+---------------+--------------------+--------------------------------------+---------+------------+---------------------+---------------------+
| f639e7a9-9609-468e-aa08-7650e1472efe | task1 | my_workflow | | 49213eb5-196c-421f-b436-775849b55040 | SUCCESS | None | 2017-03-06 11:24:11 | 2017-03-06 11:24:17 |
| d565c5a0-f46f-4ebe-8655-9eb6796307a3 | task2 | my_workflow | | 49213eb5-196c-421f-b436-775849b55040 | SUCCESS | None | 2017-03-06 11:24:17 | 2017-03-06 11:24:18 |
+--------------------------------------+-------+---------------+--------------------+--------------------------------------+---------+------------+---------------------+---------------------+
Check the result of task *'task1'*::
$ mistral task-get-result f639e7a9-9609-468e-aa08-7650e1472efe
[
"John",
"Mistral",
"Ivan",
"Crystal"
]
If needed, we can go deeper and look at a list of the results of the
**action_executions** of a single task::
$ mistral action-execution-list f639e7a9-9609-468e-aa08-7650e1472efe
+--------------------------------------+----------+---------------+--------------------+-----------+--------------------------------------+---------+----------+---------------------+---------------------+
| ID | Name | Workflow name | Workflow namespace | Task name | Task ID | State | Accepted | Created at | Updated at |
+--------------------------------------+----------+---------------+--------------------+-----------+--------------------------------------+---------+----------+---------------------+---------------------+
| 4e0a60be-04df-42d7-aa59-5107e599d079 | std.echo | my_workflow | | task1 | f639e7a9-9609-468e-aa08-7650e1472efe | SUCCESS | True | 2017-03-06 11:24:12 | 2017-03-06 11:24:16 |
| 5bd95da4-9b29-4a79-bcb1-298abd659bd6 | std.echo | my_workflow | | task1 | f639e7a9-9609-468e-aa08-7650e1472efe | SUCCESS | True | 2017-03-06 11:24:12 | 2017-03-06 11:24:16 |
| 6ae6c19e-b51b-4910-9e0e-96c788093715 | std.echo | my_workflow | | task1 | f639e7a9-9609-468e-aa08-7650e1472efe | SUCCESS | True | 2017-03-06 11:24:12 | 2017-03-06 11:24:16 |
| bed5a6a2-c1d8-460f-a2a5-b36f72f85e19 | std.echo | my_workflow | | task1 | f639e7a9-9609-468e-aa08-7650e1472efe | SUCCESS | True | 2017-03-06 11:24:12 | 2017-03-06 11:24:17 |
+--------------------------------------+----------+---------------+--------------------+-----------+--------------------------------------+---------+----------+---------------------+---------------------+
Check the result of the first **action_execution**::
$ mistral action-execution-get-output 4e0a60be-04df-42d7-aa59-5107e599d079
{
"result": "John"
}
**Congratulations! Now you are ready to use OpenStack Workflow Service!**
|