fuel-plugin-cinder-gcs/examples/mistral_workbook.yaml
Taras Kostyuk dbc79569d4 Mistral sample workbook
Change-Id: I1224d44a6acb7ac09af06919f70e77bd6b20278a
2016-08-08 16:28:47 +03:00

131 lines
4.5 KiB
YAML

---
version: '2.0'
name: sample_backup_workbook
description: Sample backup workflows
# Ad-hoc Actions
actions:
send_email:
input:
- to_addrs
- subject
- body
base: std.email
base-input:
to_addrs: <% $.to_addrs %>
subject: <% $.subject %>
body: <% $.body %>
from_addr: 'mistral@localhost'
smtp_server: 'localhost'
smtp_password: 'SECRET'
# Workflows
workflows:
create_backups_workflow:
type: direct
description: Sample workflow to create backups
input:
- projects_id_list: null
- volumes_id_list: null
- incremental: false
- report_to_list: null
- snapshot_name: 'by_create_backups_workflow'
tasks:
analyze_volumes_id_list:
action: std.echo output=<% $.volumes_id_list %>
publish:
volumes_id_list_to_snapshot: <% $.volumes_id_list %>
on-success:
- analyze_projects_id_list: <% isList($.volumes_id_list) = false %>
- create_snapshots: <% isList($.volumes_id_list) %>
analyze_projects_id_list:
action: std.echo output=<% $.projects_id_list %>
on-success:
- get_all_projects_volumes_list: <% $.projects_id_list = null %>
- get_volumes_list: <% $.projects_id_list != null %>
get_all_projects_volumes_list:
action: cinder.volumes_list search_opts=<% {'all_tenants'=>1} %>
publish:
volumes_id_list_to_snapshot: <% task(get_all_projects_volumes_list).result.id %>
on-success:
- create_snapshots: <% task(get_all_projects_volumes_list).result != [] %>
get_volumes_list:
with-items: project_id in <% $.projects_id_list %>
action: cinder.volumes_list search_opts=<% {'all_tenants'=>1,'project_id'=> $.project_id} %>
publish:
volumes_id_list_to_snapshot: <% task(get_volumes_list).result.id %>
on-success:
- create_snapshots: <% task(get_volumes_list).result != [] %>
create_snapshots:
with-items: volume_id_to_snapshot in <% $.volumes_id_list_to_snapshot %>
action: cinder.volume_snapshots_create volume_id=<% $.volume_id_to_snapshot %> force=true name=<% $.snapshot_name %> description='Temporaray snapshot created by Mistral for backup purpose'
on-complete: create_backups
create_backups:
with-items:
- snap_id in <% task(create_snapshots).result.id %>
- vol_id in <% task(create_snapshots).result.volume_id %>
action: cinder.backups_create snapshot_id=<% $.snap_id %> volume_id=<% $.vol_id %> incremental=<% $.incremental %>
publish:
backups_id_list: <% task(create_backups).result.id %>
on-complete: wait_for_backups_completion
wait_for_backups_completion:
with-items: backup_id in <% $.backups_id_list %>
action: cinder.backups_get backup_id=<% $.backup_id %>
publish:
snap_id_to_del_list: <% task(wait_for_backups_completion).result.where($.status != creating).snapshot_id %>
on-complete: delete_snapshots
wait-before: 10
timeout: 300
retry:
count: 30
delay: 10
continue-on: <% creating in task(wait_for_backups_completion).result.status %>
delete_snapshots:
description: Deletes snapshots for backups which are not in creating state
with-items: snap_id_to_del in <% $.snap_id_to_del_list %>
action: cinder.volume_snapshots_delete snapshot=<% $.snap_id_to_del %>
on-success:
- report_success: <% ( $.volumes_id_list_to_snapshot.len() = $.snap_id_to_del_list.len() ) and ( $.report_to_list != null ) %>
- report_error: <% ( $.volumes_id_list_to_snapshot.len() != $.snap_id_to_del_list.len() ) and ( $.report_to_list != null ) %>
on-error:
- report_error: <% $.report_to_list != null %>
report_error:
action: send_email
input:
to_addrs: <% $.report_to_list %>
subject: 'Sample backup workflow - Error'
body: |
Hi,
Please take a look at Mistral Dashboard to find out what's wrong
with your workflow execution <% execution().id %>.
Everything's going to be alright!
-- Regards, Sample backup workflow.
report_success:
action: send_email
input:
to_addrs: <% $.report_to_list %>
subject: 'Sample backup workflow - Success'
body: |
Hi,
The backups has been created.
-- Regards, Sample backup workflow.