2014-10-05 12:56:37 -07:00
|
|
|
Quick Start
|
2015-08-04 15:06:47 +03:00
|
|
|
===========
|
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
Prerequisites
|
|
|
|
-------------
|
|
|
|
|
|
|
|
Before you start following this guide, make sure you have completed these
|
|
|
|
three prerequisites.
|
|
|
|
|
2015-08-27 15:31:51 +03:00
|
|
|
Install and Run Mistral
|
2016-09-29 11:24:39 +01:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
Go through the installation manual: :doc:`Mistral Installation Guide </guides/installation_guide>`
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
Install Mistral Client
|
2016-09-29 11:24:39 +01:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
To install mistralclient, please refer to :doc:`Mistral Client / CLI Guide </guides/mistralclient_guide>`
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
Export Keystone Credentials
|
2016-09-29 11:24:39 +01:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
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``:
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
.. code-block:: bash
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
$ 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
|
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
Write a Workflow
|
|
|
|
----------------
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
For example, we have the following workflow.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
---
|
|
|
|
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:
|
2016-02-01 23:04:25 +13:00
|
|
|
action: std.echo output="Done"
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
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 DSL specification </dsl/dsl_v2>`
|
2015-10-13 13:27:47 +06:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
Upload the Workflow
|
|
|
|
-------------------
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
Use the *Mistral CLI* to create the workflow::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
$ mistral workflow-create <workflow.yaml>
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
The output should look similar to this::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
+-------------+--------+---------+---------------------+------------+
|
|
|
|
| Name | Tags | Input | Created at | Updated at |
|
|
|
|
+-------------+--------+---------+---------------------+------------+
|
|
|
|
| my_workflow | <none> | names | 2015-08-13 08:44:49 | None |
|
|
|
|
+-------------+--------+---------+---------------------+------------+
|
|
|
|
|
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
Run the Workflow and Check the Result
|
|
|
|
-------------------------------------
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
Use the *Mistral CLI* to start the new workflow, passing in a list of names
|
|
|
|
as JSON::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
$ mistral execution-create my_workflow '{"names": ["John", "Mistral", "Ivan", "Crystal"]}'
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-07-15 18:43:33 +01:00
|
|
|
Make sure the output is like the following::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
+-------------+--------------------------------------+
|
|
|
|
| Field | Value |
|
|
|
|
+-------------+--------------------------------------+
|
|
|
|
| ID | 056c2ed1-695f-4ccd-92af-e31bc6153784 |
|
|
|
|
| Workflow | my_workflow |
|
|
|
|
| Description | |
|
|
|
|
| State | RUNNING |
|
|
|
|
| State info | None |
|
|
|
|
| Created at | 2015-08-28 09:05:00.065917 |
|
|
|
|
| Updated at | 2015-08-28 09:05:00.844990 |
|
|
|
|
+-------------+--------------------------------------+
|
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
After a moment, check the status of the workflow execution (replace the
|
|
|
|
example execution id with the ID output above)::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
$ mistral execution-get 056c2ed1-695f-4ccd-92af-e31bc6153784
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
+-------------+--------------------------------------+
|
|
|
|
| Field | Value |
|
|
|
|
+-------------+--------------------------------------+
|
|
|
|
| ID | 056c2ed1-695f-4ccd-92af-e31bc6153784 |
|
|
|
|
| Workflow | my_workflow |
|
|
|
|
| Description | |
|
|
|
|
| State | SUCCESS |
|
|
|
|
| State info | None |
|
|
|
|
| Created at | 2015-08-28 09:05:00 |
|
|
|
|
| Updated at | 2015-08-28 09:05:03 |
|
|
|
|
+-------------+--------------------------------------+
|
|
|
|
|
2016-07-15 18:43:33 +01:00
|
|
|
The status of each **task** also can be checked::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
$ mistral task-list 056c2ed1-695f-4ccd-92af-e31bc6153784
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
+--------------------------------------+-------+---------------+--------------------------------------+---------+
|
|
|
|
| ID | Name | Workflow name | Execution ID | State |
|
|
|
|
+--------------------------------------+-------+---------------+--------------------------------------+---------+
|
|
|
|
| 91874635-dcd4-4718-a864-ac90408c1085 | task1 | my_workflow | 056c2ed1-695f-4ccd-92af-e31bc6153784 | SUCCESS |
|
|
|
|
| 3bf82863-28cb-4148-bfb8-1a6c3c115022 | task2 | my_workflow | 056c2ed1-695f-4ccd-92af-e31bc6153784 | SUCCESS |
|
|
|
|
+--------------------------------------+-------+---------------+--------------------------------------+---------+
|
|
|
|
|
2016-07-15 18:43:33 +01:00
|
|
|
Check the result of task *'task1'*::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
$ mistral task-get-result 91874635-dcd4-4718-a864-ac90408c1085
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
[
|
|
|
|
"John",
|
|
|
|
"Mistral",
|
|
|
|
"Ivan",
|
|
|
|
"Crystal"
|
|
|
|
]
|
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
If needed, we can go deeper and look at a list of the results of the
|
|
|
|
**action_executions** of a single task::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
$ mistral action-execution-list 91874635-dcd4-4718-a864-ac90408c1085
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
+--------------------------------------+----------+---------------+-----------+---------+------------+-------------+
|
|
|
|
| ID | Name | Workflow name | Task name | State | State info | Is accepted |
|
|
|
|
+--------------------------------------+----------+---------------+-----------+---------+------------+-------------+
|
2016-07-15 18:43:33 +01:00
|
|
|
| 20c2b65d-b899-437f-8e1b-50fe477fbf4b | std.echo | my_workflow | task1 | SUCCESS | None | True |
|
|
|
|
| 6773c887-6eff-46e6-bed9-d6b67d77813b | std.echo | my_workflow | task1 | SUCCESS | None | True |
|
|
|
|
| 753a9e39-d93e-4751-a3c1-569d1b4eac64 | std.echo | my_workflow | task1 | SUCCESS | None | True |
|
|
|
|
| 9872ddbc-61c5-4511-aa7e-dc4016607822 | std.echo | my_workflow | task1 | SUCCESS | None | True |
|
2015-08-27 15:31:51 +03:00
|
|
|
+--------------------------------------+----------+---------------+-----------+---------+------------+-------------+
|
|
|
|
|
2016-07-15 18:43:33 +01:00
|
|
|
Check the result of the first **action_execution**::
|
2015-08-27 15:31:51 +03:00
|
|
|
|
2016-09-29 11:24:39 +01:00
|
|
|
$ mistral action-execution-get-output 20c2b65d-b899-437f-8e1b-50fe477fbf4b
|
2015-08-27 15:31:51 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
"result": "John"
|
|
|
|
}
|
|
|
|
|
|
|
|
**Congratulations! Now you are ready to use OpenStack Workflow Service!**
|