(Click to open topic with navigation)
The following procedure details the steps required to create a workflow that builds a VM. This workflow contains four job templates:
Image 22-2: Sample cloud workflow in submit order |
Click to enlarge |
Image 22-3: Sample cloud workflow in run order |
Click to enlarge |
To create a generic system job workflow
JOBCFG[createVM] GENERICSYSJOB=EType=start,AType=exec,Action="$HOME/installVM.py $HOSTLIST",Timeout=1:00:00,sets=^IPAddr
JOBCFG[createVM] INHERITRES=TRUE
createVM
job using the TEMPLATEDEPEND attribute (see the Job Dependency Syntax table for options). In this example, the installSoftware job begins after the createVM job completes successfully.JOBCFG[installSoftware] GENERICSYSJOB=EType=start,AType=exec,Action="$HOME/setupSoftware.py $IPAddr",Timeout=30:00,Flags=objectxmlstdin
JOBCFG[installSoftware] INHERITRES=TRUE
JOBCFG[installSoftware] TEMPLATEDEPEND=AFTEROK:createVM
If you are using your workflow in Moab Web Services or Viewpoint, the trigger attached to the last setup job must pass up the Deployed variable upon success.
JOBCFG[createVMWithSoftware] TEMPLATEDEPEND=AFTEROK:installSoftware SELECT=TRUE FLAGS=NORMSTART,VMTRACKING
JOBCFG[createVMWIthSoftware] DESTROYTEMPLATE=destroy
JOBCFG[destroy] GENERICSYSJOB=EType=start,AType=exec,Action="$HOME/destroy.py $IPAddr",timeout=5:00
If you wish to implement an automatic VM migration policy, you must similarly configure a migration job and link to it via the MIGRATETEMPLATE attribute.
> msub -l walltime=2:00:00,template=createVMWithSoftware,nodes=1:ppn=4,mem=1024 anyScript.py
If ENABLEVMDESTROY is FALSE (default), Moab puts the VM-tracking job on hold when a VM build times out rather than deleting it. The job is visible in the showq report. Releasing the job hold causes Moab to attempt to pick up the VM again.
Moab creates a job and applies the createVMWithSoftware template to it. This includes the creation of the installSoftware and createVM jobs. The INHERITRES attribute causes the new jobs to adopt the same resource request as createVMWithSoftware (4 processors and 1 GB of memory). Moab then applies their own templates.
The createVM job runs first, the trigger script returning the IP address of the new VM and setting it as a variable. The job passes its allocation to the installSoftware job. installSoftware uses the IP address variable to locate the VM and install software on it. The job returns its resources to createVMWithSoftware, which is now the VM-tracking job.