Go to main content

Oracle® ZFS Storage Appliance Administration Guide, Release OS8.7.x

Exit Print View

Updated: September 2017
 
 

Coding Workflow Schedules

Schedules can also be specified in the workflow code as a property in the Object workflow. The property syntax used here differs from the CLI schedule creation. Here three properties are used,

Table 150  Workflow Schedule Properties
Property
Type
Description
offset
Number
Determines the starting point in the defined period
period
Number
Defines the frequency of the Schedule
unit
String
Specifies if either seconds or month are used as unit in the offset and period definition
Example 29  Illustrating the Use of Workflow Properties

The following code example illustrates the use of the properties. Note that inline arithmetic helps to make the offset and period declarations more readable.

// Example of using Schedule definitions within a workflow 
var MyTextObject = {	 
	MyVersion:	'1.0', 
	MyName:		'Example 9',
	MyDescription: 	'Example of use of Timer',
	Origin:		'Oracle'
 }; 
var MySchedules = [
	// half hr interval
	{ offset: 0, period: 1800, units: "seconds" },
	// offset 2 days, 4hr, 30min , week interval
	{offset: 2*24*60*60+4*60*60+30*60, period: 604800,units: "seconds" } 
];
var workflow = { 
	name:		MyTextObject.MyName, 
	description:	MyTextObject.MyDescription, 
	version:	MyTextObject.MyVersion,
	alert:		false,
	setid:		true, 
	schedules: 	MySchedules,
	scheduled:	true,
	origin:		MyTextObject.Origin, 
	execute:	function () { 			
				audit('workflow started for timer; ');
				 } 
			}
 }; 

The property units in the Object MySchedules specifies the type of units used for the properties offset and period. They can be set to either seconds or month. The property period specifies the frequency of the event and the offset specifies the units within the period. In the above example the period in the second schedule is set for a week, starting at the second day, at 4:30. Multiple schedules can be defined in the property schedules.

The Object MySchedules in the example uses the following three properties:

  • offset - This is the starting offset from January 1, 1970 for the schedule. The offset is given in the units defined by the property "units".

  • period - This is the period between recurrences of the schedule which is also given in the units defined by the property "units".

  • units - This can be defined in seconds or months.

The starting point for weekly schedules is Thursday. This is due to the fact that the epoch is defined as starting on 1 Jan 1970 which was a Thursday.

Example 30  Workflow Schedule Shown in the CLI

In the above example the period in the second schedule uses a starting offset of 2 days + 4 hours + 30 minutes. This results in the starting date being January 3, 1970 at 4:30 am. The schedule recurs weekly indefinitely every Saturday at 4:30 am. Below you can see the display of the schedule in the CLI.

<small>dory:> maintenance workflows
dory:maintenance workflows> list
WORKFLOW     NAME                       OWNER SETID ORIGIN               VERSION
workflow-000 Configure for Oracle Solaris Cluster NFS root  false Oracle Corporation   1.0.0
workflow-001 Unconfigure Oracle Solaris Cluster NFS root  false Oracle Corporation   1.0.0
workflow-002 Configure for Oracle Enterprise Manager Monitoring root  false Sun Microsystems, Inc. 1.1
workflow-003 Unconfigure Oracle Enterprise Manager Monitoring root  false Sun Microsystems, Inc. 1.0</small>

dory:maintenance workflow-002 schedules>

NAME                 FREQUENCY            DAY                  HH:MM
schedule-000         halfhour             -                    --:00
schedule-001         week                 Saturday             04:30