2.3 JDL Job Scripts

The Orchestrator job definition language (JDL) is an extended and embedded implementation of Python. It is completely multi-threaded. The developer of the job has full access to the Python language and standard extensions, and the ZENworks Orchestrator system provides additional constructs to control and access the following:

For more information about the Orchestrator JDL script editor, see Section 7.2, JDL Package or JDL Editor in the Novell ZENworks Orchestrator 1.3 Installation and Getting Started Guide.

The JDL language allows for the scripted construction of test cases that can be driven by external parameters and constraints at the time the job instance is executed. In addition, the development of a job with the JDL (Python) language is very straightforward. For a listing of the job, joblet, and utility classes, see Section A.0, Orchestrator Job Classes and JDL Syntax.

A simple “hello world” Python script example that runs a given number of times (numTests) in parallel (subject to resource availability and policy) is shown below:

class exampleJob(Job):
    def job_started_event(self):
        print 'Hello world started: got job_started_event'
        # Launch the joblets
        numJoblets = self.getFact("jobargs.numTests")
        pspace = ParameterSpace()
        i = 1
        while i <= numJoblets:
            i += 1
        self.schedule(exampleJoblet, pspace, {})

class exampleJoblet(Joblet):
    def joblet_started_event(self):
        print "Hello from resource%s" % self.getFact("resource.id")

This example script contains two sections:

Because the resources are not requested explicitly, they are allocated based on the resource constraints associated with this job (or user and relevant groups). If none are specified, all resources match. The exampleJoblet class would typically execute some process or test based on unique parameters.

Finally, the ParameterSpace object accesses the built in “grid” ability of the Orchestrator Server, which is the way to describe the parallel inherent in a problem. In this example, the simple addition of appendRows() indicates that each joblet can run in parallel. This guide provides information to create much more sophisticated constructs.

2.3.1 Principles of Job Operation

Whenever a job is run on the Orchestrator system it undergoes state transition, as illustrated in Figure 2-15. In all, there are 11 states. The following four states are important in understanding how constraints are applied on a job’s life cycle through policies:

Accept: Used to prevent work from starting; enforces a hard quota on the jobs.

Start: Used to queue up work requests; limits the quantity of jobs or the load on a resource.

Resource: Used to select specific resources.

Stop: Used to abort jobs; provides special timeout or overrun conditions.

Figure 2-15 Constraint-Based Job State Transition

For more information about job life cycle, see Section 7.3.1, Job State Transition Events.