Contents

  1. Introduction
  2. Date
  3. List
  4. Unzip and Resize
  5. ls | wc -l

Introduction

Here are some workflow examples; you can download them by clicking the zip icon in each section (next to the "Workflow" subtitle).

Date

Description

This is a very simple workflow that uses the GNU command “date” to print the current date and time.

Tasks definitions

Task namedate
Task binary/bin/date
Parameters modeCMDLINE
Output typeTEXT

Workflow

<workflow>
<parameters></parameters>
<subjobs>
<job>
<tasks>
<task name="datequeue="default"></task>
</tasks>
</job>
</subjobs>
</workflow>

Workflow Instance

<workflow end_time="2015-03-01 16:41:37errors="0id="159name="ex_datestart_time="2015-03-01 16:41:37status="TERMINATED">
<parameters></parameters>
<subjobs>
<job>
<tasks>
<task execution_time="2015-03-01 16:41:37name="datequeue="defaultretval="0status="TERMINATED">
<output execution_time="2015-03-01 16:41:37exit_time="2015-03-01 16:41:37method="textretval="0">Sun Mar 1 16:41:37 CET 2015 </output>
</task>
</tasks>
</job>
</subjobs>
</workflow>

List

Description

We will now see how to pass parameters to a workflow, and how a task can read these parameters. We will create a new workflow that will list files in the directory passed as argument using the “ls” command.

Tasks definitions

Task namels
Task binary/bin/ls
Parameters modeCMDLINE
Output typeTEXT

Workflow

<workflow>
<parameters>
<parameter name="filename"></parameter>
</parameters>
<subjobs>
<job>
<tasks>
<task name="lsqueue="default">
<input name="filename">
<value select="/workflow/parameters/parameter[@name='filename']"></value>
</input>
</task>
</tasks>
</job>
</subjobs>
</workflow>

Workflow Instance

<workflow end_time="2015-02-26 13:48:29errors="0id="143name="ex_lsstart_time="2015-02-26 13:48:29status="TERMINATED">
<parameters>
<parameter name="filename">/var</parameter>
</parameters>
<subjobs>
<job>
<tasks>
<task execution_time="2015-02-26 13:48:29name="lsqueue="defaultretval="0status="TERMINATED">
<input name="filename">/var</input>
<output execution_time="2015-02-26 13:48:29exit_time="2015-02-26 13:48:29method="textretval="0">agentx backups cache chef lib local lock log lost+found mail opt run spool tmp www </output>
</task>
</tasks>
</job>
</subjobs>
</workflow>

Unzip and Resize

Description

This workflow takes a zip filename as parameter. It will then unzip the file and resize pictures contained in it.

Tasks definitions

Task nameex-unzip
Task binaryex-resize/unzip.sh
Parameters modeCMDLINE
Output typeXML
Task nameex-resize
Task binaryex-resize/resize.sh
Parameters modeCMDLINE
Output typeTEXT

Workflow

<workflow>
<parameters>
<parameter name="zip_filename"></parameter>
</parameters>
<subjobs>
<job>
<tasks>
<task name="ex-unzipqueue="default">
<input name="zip_filename">
<value select="/workflow/parameters/parameter[@name='zip_filename']"></value>
</input>
</task>
</tasks>
<subjobs>
<job>
<tasks>
<task loop="/workflow/subjobs/job/tasks/task[@name='ex-unzip']/output/zip/imagename="ex-resizequeue="default"></task>
</tasks>
</job>
</subjobs>
</job>
</subjobs>
</workflow>

Workflow Instance

<workflow end_time="2015-02-26 23:26:50errors="0id="148name="ex_resizestart_time="2015-02-26 23:26:50status="TERMINATED">
<parameters>
<parameter name="zip_filename">/tmp/photos.zip</parameter>
</parameters>
<subjobs>
<job>
<tasks>
<task execution_time="2015-02-26 23:26:50name="ex-unzipqueue="defaultretval="0status="TERMINATED">
<input name="zip_filename">/tmp/photos.zip</input>
<output execution_time="2015-02-26 23:26:50exit_time="2015-02-26 23:26:50method="xmlretval="0">
<zip>
<image>img1.jpg</image>
<image>img2.jpg</image>
<image>img3.jpg</image>
</zip>
</output>
</task>
</tasks>
<subjobs>
<job>
<tasks>
<task execution_time="2015-02-26 23:26:50name="ex-resizequeue="defaultretval="0status="TERMINATED">
<output execution_time="2015-02-26 23:26:50exit_time="2015-02-26 23:26:50method="textretval="0">Resized </output>
</task>
<task execution_time="2015-02-26 23:26:50name="ex-resizequeue="defaultretval="0status="TERMINATED">
<output execution_time="2015-02-26 23:26:50exit_time="2015-02-26 23:26:50method="textretval="0">Resized </output>
</task>
<task execution_time="2015-02-26 23:26:50name="ex-resizequeue="defaultretval="0status="TERMINATED">
<output execution_time="2015-02-26 23:26:50exit_time="2015-02-26 23:26:50method="textretval="0">Resized </output>
</task>
</tasks>
</job>
</subjobs>
</job>
</subjobs>
</workflow>

ls | wc -l

Description

This workflow show how to use the "stdin" input type. It simulates the command "ls | wc -l" to count the number of entries in a directory passed as argument.

Tasks definitions

Task namels
Task binary/bin/ls
Parameters modeCMDLINE
Output typeTEXT
Task namewc
Task binary/usr/bin/wc
Parameters modeCMDLINE
Output typeTEXT

Workflow

<workflow>
<parameters>
<parameter name="dirname"></parameter>
</parameters>
<subjobs>
<job>
<tasks>
<task name="lsqueue="default">
<input name="filename">
<value select="/workflow/parameters/parameter[@name='dirname']"></value>
</input>
</task>
</tasks>
<subjobs>
<job>
<tasks>
<task name="wcqueue="default">
<input name="count">-l</input>
<stdin>
<value select="/workflow/subjobs/job/tasks/task[@name='ls']/output"></value>
</stdin>
</task>
</tasks>
</job>
</subjobs>
</job>
</subjobs>
</workflow>

Workflow Instance

<workflow end_time="2015-03-08 20:03:58errors="0id="16name="ex_lswcstart_time="2015-03-08 20:03:58status="TERMINATED">
<parameters>
<parameter name="dirname">/</parameter>
</parameters>
<subjobs>
<job>
<tasks>
<task execution_time="2015-03-08 20:03:58name="lsqueue="defaultretval="0status="TERMINATED">
<input name="filename">/</input>
<output execution_time="2015-03-08 20:03:58exit_time="2015-03-08 20:03:58method="textretval="0">bin boot data dev etc home initrd.img initrd.img.old lib lib32 lib64 lost+found media mnt opt proc root run sbin selinux sharedance srv sys tftproot tmp usr var vmlinuz vmlinuz.old </output>
</task>
</tasks>
<subjobs>
<job>
<tasks>
<task execution_time="2015-03-08 20:03:58name="wcqueue="defaultretval="0status="TERMINATED">
<input name="count">-l</input>
<stdin>bin boot data dev etc home initrd.img initrd.img.old lib lib32 lib64 lost+found media mnt opt proc root run sbin selinux sharedance srv sys tftproot tmp usr var vmlinuz vmlinuz.old </stdin>
<output execution_time="2015-03-08 20:03:58exit_time="2015-03-08 20:03:58method="textretval="0">29 </output>
</task>
</tasks>
</job>
</subjobs>
</job>
</subjobs>
</workflow>