Last active
June 11, 2019 15:08
-
-
Save bogdando/f2488c07739cd25af551bf77d33c907d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# Based on http://www.dougalmatthews.com/2017/Jan/31/interactive-mistral-workflows-over-zaqar/ | |
. stackrc | |
export OS_CACERT=${1:-/etc/pki/ca-trust/source/anchors/cm-local-ca.pem} | |
cat > test <<EOF | |
--- | |
version: '2.0' | |
interactive-workflow: | |
input: | |
- input_queue: "workflow-input" | |
- output_queue: "workflow-output" | |
tasks: | |
request_user_input: | |
action: zaqar.queue_post | |
retry: count=5 delay=1 | |
input: | |
queue_name: <% $.output_queue %> | |
messages: | |
body: "Send some input to '<% $.input_queue %>'" | |
on-success: read_user_input | |
read_user_input: | |
pause-before: true | |
action: zaqar.queue_pop | |
input: | |
queue_name: <% $.input_queue %> | |
publish: | |
user_input: <% task(read_user_input).result %> | |
on-success: done | |
done: | |
action: std.echo output=<% $.user_input %> | |
action: zaqar.queue_post | |
retry: count=5 delay=1 | |
input: | |
queue_name: <% $.output_queue %> | |
messages: | |
body: "You sent: '<% $.user_input %>'" | |
EOF | |
openstack messaging queue delete workflow-input | |
openstack messaging queue delete workflow-output | |
openstack messaging queue create workflow-input | |
openstack messaging queue create workflow-output | |
name="interactive-workflow" | |
mistral workflow-delete $name | |
mistral workflow-create test | |
mistral execution-create $name | |
ID=$(mistral execution-list -c ID -c 'Workflow name' | awk -v n=$name '/n/ {print $2}' | tail -1) | |
mistral execution-get $ID | |
mistral run-action --os-cacert=$OS_CACERT zaqar.queue_post '{"queue_name": "workflow-input", "messages":{"body":{"testing":123}}}' | |
mistral execution-get $ID | |
mistral execution-update -s RUNNING $ID | |
mistral execution-get $ID | |
mistral run-action --os-cacert=$OS_CACERT zaqar.queue_pop '{"queue_name": "workflow-output"}' | |
mistral execution-get $ID | |
read | |
mistral execution-delete $ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment