In this recipe, you will learn how to schedule workflows. Scheduled workflows will automatically run at given times and intervals.
We need at least one workflow we can schedule. The workflow should not contain a user interaction.
Using the Orchestrator scheduler allows you to make sure certain tasks are running at a specific time. There are multiple examples. There is a maintenance task that is scheduled to run every evening to disconnect all CD-ROM drives from VMs or a provisioning/decommissioning task that you want to enact at a certain time. However, you could also use a policy for this, see the Working with policies recipe in Chapter 8, Better Workflows and Optimized Working.
You can manage all scheduled tasks from the Run | Scheduler view. Here, you can review all the relevant information for all the scheduled tasks. The information provided includes what workflow it is currently running when the last run was made, and when it will run next; you also see the in-parameters (Parameters) you have supplied to the workflow. By right-clicking on the task, you can suspend and resume it as well as cancel/delete and edit it. When editing the task, you can change all settings with regard to the scheduling; however, you cannot change the workflow you have scheduled or the in-parameters you entered when you scheduled the task:
If you click on the Workflow Runs tab, you can see all the information for each run. You see the start and end time as well as the workflow state (waiting, failed, completed, canceled, running). If the workflow is currently running, you can see which element of the workflow is currently running (Current item) as well as its business state:
In addition to this, you can also schedule and monitor a scheduled task from vCenter. In the vCenter Web Client, click on vCenter Orchestrator and then on Scheduled workflows.
You can interactively schedule a workflow using a workflow. A typical example for this is a workflow that requests a VM but then schedules the actual provisioning at a later date and time. To do this, just use the Schedule workflow schema element that you find in the Generic section. This element only schedules tasks once; it doesn't allow recurring tasks.
You can schedule workflows using JavaScript. By using the two Workflow.schedule()
and Workflow.scheduleRecurrently()
methods, you can now schedule this workflow. Have a closer look at the Schedule workflow schema element; the Workflow.schedule()
method is used there.