Demonstrates a job starting up multiple instances of a joblet on one or more resources. Because this job simply launches and returns immediately, it can also be useful for testing network latency.
> zos login --user zenuser Please enter current password for 'zenuser': Logged into grid as zenuser > zos jobinfo --detail quickie Jobname/Parameters Attributes ------------------ ---------- quickie Desc: This example job does absolutely nothing. It just returns immediately. For testing network latency. sleeptime Desc: time to sleep (in seconds) Type: Integer Default: 0 numJoblets Desc: joblets to run Type: Integer Default: 100
The files that make up the Quickie job include:
quickie # Total: 88 lines |-- quickie.jdl # 48 lines `-- quickie.policy # 40 lines
1 # ----------------------------------------------------------------------------- 2 # Copyright © 2008 Novell, Inc. All Rights Reserved. 3 # 4 # NOVELL PROVIDES THE SOFTWARE "AS IS," WITHOUT ANY EXPRESS OR IMPLIED 5 # WARRANTY, INCLUDING WITHOUT THE IMPLIED WARRANTIES OF MERCHANTABILITY, 6 # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGMENT. NOVELL, THE AUTHORS 7 # OF THE SOFTWARE, AND THE OWNERS OF COPYRIGHT IN THE SOFTWARE ARE NOT LIABLE 8 # FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 9 # TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE 10 # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 # ----------------------------------------------------------------------------- 12 # $Id: quickie.jdl,v 1.3 2008/02/27 20:51:13 john Exp $ 13 # ----------------------------------------------------------------------------- 14 15 import time 16 17 # 18 # Add to the 'examples' group on deployment 19 # 20 if __mode__ == "deploy": 21 try: 22 jobgroupname = "examples" 23 jobgroup = getMatrix().getGroup(TYPE_JOB, jobgroupname) 24 if jobgroup == None: 25 jobgroup = getMatrix().createGroup(TYPE_JOB, jobgroupname) 26 jobgroup.addMember(__jobname__) 27 except: 28 exc_type, exc_value, exc_traceback = sys.exc_info() 29 print "Error adding %s to %s group: %s %s" % (__jobname__, jobgroupname, exc_type, exc_value) 30 31 32 class quickieJob(Job): 33 34 def job_started_event(self): 35 36 # Launch the joblets 37 numJoblets = self.getFact("jobargs.numJoblets") 38 print 'Launching ', numJoblets, ' joblets' 39 40 self.schedule(quickieJoblet, numJoblets) 41 42 43 class quickieJoblet(Joblet): 44 45 def joblet_started_event(self): 46 self.setFact("joblet.memo", "quickie's memo - joblet started") 47 sleeptime = self.getFact("jobargs.sleeptime") 48 time.sleep(sleeptime)
1 <!-- 2 *============================================================================= 3 * Copyright © 2008 Novell, Inc. All Rights Reserved. 4 * 5 * NOVELL PROVIDES THE SOFTWARE "AS IS," WITHOUT ANY EXPRESS OR IMPLIED 6 * WARRANTY, INCLUDING WITHOUT THE IMPLIED WARRANTIES OF MERCHANTABILITY, 7 * FITNESS FOR A PARTICULAR PURPOSE, AND NON INFRINGMENT. NOVELL, THE AUTHORS 8 * OF THE SOFTWARE, AND THE OWNERS OF COPYRIGHT IN THE SOFTWARE ARE NOT LIABLE 9 * FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 10 * TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE 11 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 *============================================================================= 13 * $Id: quickie.policy,v 1.2 2008/02/27 20:51:13 john Exp $ 14 *============================================================================= 15 --> 16 17 <policy> 18 19 <jobargs> 20 <fact name="numJoblets" 21 type="Integer" 22 description="joblets to run" 23 value="100" 24 visible="true" /> 25 26 <fact name="sleeptime" 27 type="Integer" 28 description="time to sleep (in seconds)" 29 value="0" 30 visible="true" /> 31 </jobargs> 32 33 <job> 34 <fact name="description" 35 type="String" 36 value="This example job does absolutely nothing. It just returns immediately. For testing network latency." /> 37 </job> 38 39 </policy> 40
A representation of a running job instance.
Defines execution on the resource.
A representation of the matrix grid object, which provides operations for retrieving and creating grid objects in the system. MatrixInfo is retrieved using the built-in getMatrix() function. Write capability is dependent on the context in which getMatrix() is called. For example, in a joblet process on a resource, creating new grid objects is not supported.
A representation of Group grid objects. Operations include retrieving the group member lists and adding/removing from the group member lists, and retrieving and setting facts on the group.
The Quickie job can be broken down into the following separate operations:
The job is first deployed into the grid, as shown in lines 2-14 of quickie.jdl. When jobs are deployed into the grid, they can optionally be organized for grouping. In this example, the Quickie job is added to the group named examples and displays in the ZENworks Orchestrator Console in the Explorer view at the location:
/ZOS/YOUR_GRID/Jobs/examples
For a general overview of how jobs are added to groups during deployment, see Walkthrough: Deploy a Sample Job
in the Novell ZENworks Orchestrator 1.3 Installation and Getting Started Guide.
As shown in line 25 of quickie.jdl, scheduling one or more instances of the Quickie joblet to run immediately is the second operation performed by the Quickie job. When the Quickie job class receives a job_started_event() notification, it schedules the number of QuickieJoblet instances as indicated by the value of the setting numJoblets, whose value might have been supplied on the command line or from the quickie.policy file (see line 3 in quickie.policy).
The final operation performed by the Quickie job is for the joblet to sleep an amount of time as specified by the value of the setting sleeptime (see line 31 in quickie.jdl), and then exit.
Deploy quickie.job into the grid:
> zosadmin deploy quickie.job
Display the list of deployed jobs:
> zos joblist
should appear in this list.
Run the job on one or more resources using the default values for numJoblets and sleeptime:
> zos run quickie
Run the job on one or more resources using supplied values for numJoblets and sleeptime:
> zos run quickie numJoblets=10 sleeptime=3 JobID: zenuser.quickie.418 > zos status zenuser.quickie.418 Completed > zos log zenuser.quickie.418 Launching 10 joblets
Ten joblets will be run simultaneously, depending on the number of resources available in the grid and how many simultaneous jobs each resource is configured to run. After the job runs, each quickie joblet instance simply starts up, sleeps for 3 seconds, and then exits.
Setting Constraints Using Policies (Section 4.4, Policy Management and Section 5.0, Developing Policies).
Adding jobs to groups during deployment (see how the JDL code can print the ID of group of jobs in factJunction.job).
Scheduling multiple instances of a joblet