Demonstrates the usage of the various argument types that jobs can accept. These types are integer, Real, Boolean, String, Time, Date, List, Dictionary, and Array (which can contain the types Integer, Real, Boolean, Time, Date, String). For more information about how to define job arguments, and specify their values on the command line, see Section 4.0, Understanding Grid Object Facts and Computed Facts.
> zosadmin login --user zosadmin Login to server: skate Please enter current password for 'zosadmin': Logged into grid on server 'skate' > cd /opt/novell/zenworks/zos/server/examples > zosadmin deploy jobargs.job jobargs successfully deployed > zos login --user zenuser Please enter current password for 'zenuser': Logged into grid as zenuser > zos jobinfo --detail jobargs Jobname/Parameters Attributes ------------------ ---------- jobargs Desc: This example job tests all fact types. OptionalRealArray Desc: No description available. Type: Real[] Default: [1.1,2.2] RequiredRealArg Desc: No description available. Type: Real Default: None! Value must be specified RequiredDateArg Desc: No description available. Type: Date Default: None! Value must be specified OptionalListArg Desc: No description available. Type: List Default: [hi, mom, 42] OptionalIntegerArg Desc: Optional Integer Arg Type: Integer Default: 123 OptionalStringArg Desc: Optional String Arg Type: String Default: foo OptionalDateArray Desc: No description available. Type: Date[] Default: [Mon Jan 02 12:01:00 MST 2006,Tue Jan 03 12:02:00 MST 2006,Wed Jan 04 00:00:00 MST 2006] OptionalStringArray Desc: No description available. Type: String[] Default: [string1,string2] RequiredBooleanArg Desc: No description available. Type: Boolean Default: None! Value must be specified OptionalString2ArgAsTag Desc: Optional String Arg as tag Type: String Default: bar RequiredTimeArg Desc: No description available. Type: Time Default: None! Value must be specified OptionalBooleanArg Desc: Optional Boolean Arg Type: Boolean Default: true OptionalTimeArg Desc: Optional Time Arg Type: Time Default: 43260000 RequiredStringArg Desc: No description available. Type: String Default: None! Value must be specified OptionalRealArg Desc: Optional Real Arg Type: Real Default: 3.14 OptionalDateArg Desc: Optional Date Arg Type: Date Default: Mon Jan 02 12:01:00 MST 2006 RequiredIntegerArg Desc: No description available. Type: Integer Default: None! Value must be specified OptionalDictArg Desc: No description available. Type: Dictionary Default: {time=12600000, date=Sat Apr 15 00:00:00 MDT 2006, age=12, name=joe} OptionalString3ArgAsCDATA Desc: Optional String Arg as CDATA Type: String Default: this text is part of | a multi-line cdata section containing | xml <html>test</html> | <eq fact="foo.bar" value="qwerty" /> | cool! OptionalTimeArray Desc: No description available. Type: Time[] Default: [43260000,43320000] OptionalIntegerArray Desc: No description available. Type: Integer[] Default: [1,2]
The files that make up the Jobargs job include:
jobargs.job # Total: 254 lines |-- jobargs.jdl # 77 lines `-- jobargs.policy # 177 lines
1 # ----------------------------------------------------------------------------- 2 # Copyright © 2010 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: jobargs.jdl 10344 2009-11-20 21:46:43Z jastin $ 13 # ----------------------------------------------------------------------------- 14 15 """ 16 Example job showing all available job argument types. 17 18 Example cmd line to run job: 19 20 zos run jobargs RequiredTimeArg="12:01 AM" RequiredRealArg="3.14" RequiredIntegerArg="123" RequiredStringArg="foo" RequiredBooleanArg="true" RequiredDateArg="6/10/08 11:35 AM" 21 22 """ 23 24 import time 25 26 # 27 # Add to the 'examples' group on deployment 28 # 29 if __mode__ == "deploy": 30 try: 31 jobgroupname = "examples" 32 jobgroup = getMatrix().getGroup(TYPE_JOB, jobgroupname) 33 if jobgroup == None: 34 jobgroup = getMatrix().createGroup(TYPE_JOB, jobgroupname) 35 jobgroup.addMember(__jobname__) 36 except: 37 exc_type, exc_value, exc_traceback = sys.exc_info() 38 print "Error adding %s to %s group: %s %s" % (__jobname__, jobgroupname, exc_type, exc_value) 39 40 41 class jobargs(Job): 42 43 def job_started_event(self): 44 45 jobid = self.getFact("jobinstance.id") 46 print "*****Dumping %s JobInstance jobargs facts*****" % (jobid) 47 keys = self.getFactNames() 48 keys.sort() 49 for s in keys: 50 if s.startswith("jobargs"): 51 v = self.getFact(s) 52 ty = type(v) 53 54 if str(ty).endswith("Dictionary"): 55 self.dump_dict(s,v) 56 else: 57 if s.endswith("TimeArg") or s.endswith("TimeArgReq"): 58 hrs = v/3600 59 min = (v % 3600)/60 60 sec = (v % 3600) % 60 61 print "%s %s %s hrs:%d min:%d sec:%d" % (s,type(v),v,hrs,min,sec) 62 63 elif s.endswith("DateArg") or s.endswith("DateArgReq"): 64 sv = time.ctime(v) 65 print "%s %s %s" % (s,type(v),sv) 66 67 else: 68 print "%s %s %s" % (s,type(v),str(v)) 69 70 print "*****End %s dump*****" % (jobid) 71 72 #self.schedule(jobargsJoblet) 73 74 def dump_dict(self,name,dict): 75 print "Dict: %s" % (name) 76 keys = dict.keys() 77 for k in keys: 78 v = dict[k] 79 ty = type(v) 80 if k == "dob": 81 v = time.ctime(v/1000) 82 print " %s %s %s" % (k,ty,str(v)) 83 84 85 class jobargsJoblet(Joblet): 86 87 def joblet_started_event(self): 88 pass 89
1 <!-- 2 *============================================================================= 3 * Copyright © 2010 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: jobargs.policy 10344 2009-11-20 21:46:43Z jastin $ 14 *============================================================================= 15 --> 16 17 <policy> 18 19 <jobargs> 20 21 <!-- Optional job args --> 22 <fact name="OptionalDateArg" 23 description="Optional Date Arg" 24 type="Date" 25 value="1/2/06 12:01 PM"/> 26 27 <fact name="OptionalTimeArg" 28 description="Optional Time Arg" 29 type="Time" 30 value="12:01 PM"/> 31 32 <fact name="OptionalRealArg" 33 description="Optional Real Arg" 34 type="Real" 35 value="3.14" /> 36 37 <fact name="OptionalIntegerArg" 38 description="Optional Integer Arg" 39 type="Integer" 40 value="123" /> 41 42 <fact name="OptionalStringArg" 43 description="Optional String Arg" 44 type="String" 45 value="foo" /> 46 47 <fact name="OptionalString2ArgAsTag" 48 description="Optional String Arg as tag"> 49 <string>bar</string> 50 </fact> 51 52 <fact name="OptionalString3ArgAsCDATA" 53 description="Optional String Arg as CDATA"> 54 <string> 55 <![CDATA[this text is part of 56 a multi-line cdata section containing 57 xml <html>test</html> 58 <eq fact="foo.bar" value="qwerty" /> 59 cool! 60 ]]> 61 </string> 62 </fact> 63 64 <fact name="OptionalBooleanArg" 65 description="Optional Boolean Arg" 66 type="Boolean" 67 value="true" /> 68 69 <fact name="OptionalListArg"> 70 <list> 71 <listelement value="hi" type="String" /> 72 <listelement value="mom" /> 73 <listelement value="42" type="Integer" /> 74 </list> 75 </fact> 76 77 <fact name="OptionalDictArg"> 78 <dictionary> 79 <dictelement key="name" type="String" value="joe" /> 80 <dictelement key="date" type="Date" value="4/15/06" /> 81 <dictelement key="time" type="Time" value="3:30 AM" /> 82 <dictelement key="age" type="Integer" value="12" /> 83 </dictionary> 84 </fact> 85 86 <fact name="OptionalDateArray"> 87 <array> 88 <date>1/2/06 12:01 PM</date> 89 <date>1/3/06 12:02 PM</date> 90 <date>1/4/06</date> 91 </array> 92 </fact> 93 <fact name="OptionalTimeArray"> 94 <array> 95 <time>12:01 PM</time> 96 <time>12:02 PM</time> 97 </array> 98 </fact> 99 <fact name="OptionalRealArray"> 100 <array> 101 <real>1.1</real> 102 <real>2.2</real> 103 </array> 104 </fact> 105 <fact name="OptionalIntegerArray"> 106 <array> 107 <integer>1</integer> 108 <integer>2</integer> 109 </array> 110 </fact> 111 <fact name="OptionalStringArray"> 112 <array> 113 <string>string1</string> 114 <string>string2</string> 115 </array> 116 </fact> 117 <!-- Arrays of dictionary or list not currently supported 118 <fact name="OptionalDictionaryArray"> 119 <array> 120 <dictionary> 121 <dictelement key="name" type="String" value="joe" /> 122 </dictionary> 123 </array> 124 </fact> 125 --> 126 127 <!-- Required job args --> 128 <fact name="RequiredDateArg" type="Date" /> 129 <fact name="RequiredTimeArg" type="Time" /> 130 <fact name="RequiredRealArg" type="Real" /> 131 <fact name="RequiredIntegerArg" type="Integer" /> 132 <fact name="RequiredStringArg" type="String" /> 133 <fact name="RequiredBooleanArg" type="Boolean" /> 134 <!-- XXX Ooops, not currently supported without value! 135 <fact name="RequiredListArg" type="list" /> 136 <fact name="RequiredDictArg" type="dictionary" /> 137 <fact name="RequiredStringArray" type="string"> 138 <array /> 139 </fact> 140 --> 141 142 <!-- Invisible job args --> 143 <fact name="InvisibleDateArg" type="Date" value="1/2/06 12:01 PM" visible="False" /> 144 <fact name="InvisibleTimeArg" type="Time" value="12:01 PM" visible="False" /> 145 <fact name="InvisibleRealArg" type="Real" value="3.14" visible="False" /> 146 <fact name="InvisibleIntegerArg" type="Integer" value="123" visible="False" /> 147 <fact name="InvisibleStringArg" type="String" value="foo" visible="False" /> 148 <fact name="InvisibleString2Arg" visible="False" > 149 <string>bar</string> 150 </fact> 151 <fact name="InvisibleBooleanArg" type="Boolean" value="true" visible="False" /> 152 <fact name="InvisibleListArg" visible="False"> 153 <list> 154 <listelement value="hi" type="String" /> 155 <listelement value="mom" /> 156 <listelement value="42" type="integer" /> 157 </list> 158 </fact> 159 <fact name="InvisibleDictArg" visible="False"> 160 <dictionary> 161 <dictelement key="name" type="String" value="joe" /> 162 <dictelement key="date" type="Date" value="4/15/06" /> 163 <dictelement key="time" type="Time" value="3:30 AM" /> 164 <dictelement key="age" type="Integer" value="12" /> 165 </dictionary> 166 </fact> 167 168 </jobargs> 169 170 <job> 171 <fact name="description" 172 type="String" 173 value="This example job tests all fact types." /> 174 </job> 175 176 </policy> 177
1 <schedule name="jobargs" description="Run jobargs" active="true"> 2 <runjob job="jobargs" user="labuser" priority="medium" /> 3 <triggers> 4 <trigger name="trigger1" /> 5 <trigger name="trigger2" /> 6 </triggers> 7 </schedule>
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 Jobargs job performs its work by handling the following events:
In jobargs.jdl, lines 27-36 deploy the job into the grid. After jobs are deployed into the grid, they can optionally be placed in groups for organization and easy reference. In this case, the jobargs job will be added to the group named “examples”, and will show up in the PlateSpin Orchestrate Development Client in the Explorer view at the location:
/Orchestrate Servers/Grid_Name/Jobs/examples
For a general overview of how jobs are added to groups during deployment, see Walkthrough: Deploying a Sample Job
in the PlateSpin Orchestrate 2.6 Installation and Configuration Guide.
After the Jobargs job receives a job_started_event, it gets a list of all the facts available to it, as shown in line 45 of jobargs.jdl. This list is sorted, filtered according to whether or not it’s a jobarg fact, and then enumerated (lines 46-58). Each jobarg fact is printed in a “name type value” format. When the complex Dictionary type is encountered (line 52), a separate method is used to print the values for all the key-value pairs (lines 63-71).
The list of optional and required arguments for this Jobargs example are available as facts within the <jobargs> section (see lines 19-168 in jobargs.policy).
For more information about defining job arguments and their types, see Section 4.0, Understanding Grid Object Facts and Computed Facts and Section 2.3, Policies.
The Jobargs job only illustrates passing job arguments to a job. Therefore, no work is performed on the resource by the jobargsJoblet.
To run this example, you must have PlateSpin Orchestrate installed and configured properly. No agents on separate resources are required. You also must be logged into your Orchestrate Server before you run zosadmin or zos commands.
Execute the following commands to deploy and run jobargs.job:
Deploy jobargs.job into the grid:
> zosadmin deploy jobarg.job
NOTE:Run zosadmin login to log in for zos administration.
Display the list of deployed jobs:
> zos joblist
should appear in this list.
NOTE:Run zos login to run zos client jobs.
Display the list of optional and required arguments for this job:
> zos jobinfo jobargs
Run the jobargs job and view the results.
NOTE:You must supply values for TimeArgReq, RealArgReq, StringArgReq, BooleanArgReq, IntegerArgReq, and DateArgReq as follows (see jobargs.policy for the full list of arguments that can be specified):
> zos run jobargs TimeArgReq=12:01:02 RealArgReq=3.14 StringArgReq=Hello BooleanArgReq=True IntegerArgReq=42 DateArgReq="04/05/07 7:45 AM"
> zos log jobargs
Defining job arguments and their types
Using PlateSpin Orchestrate (How Do I Interact with PlateSpin Orchestrate?
)