instclients.job

Installs the ZENworks Orchestrator client applications to the specified resource machine. Note that while most of the other examples are deployed by default, this example is not.

Detail

The following concepts are demonstrated:

  • Using constraints to restrict joblet execution to a specific resource.

  • Adding files to a job’s directory in the datagrid, and retrieving them during joblet execution.

  • Using the Exec class to send a command to the operating system. The system command is invoked directly without using the system command interpreter (either cmd.exe or /bin/sh).

Usage

> 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 instclients.job
instclients successfully deployed

> zos login --user zenuser
Please enter current password for 'zenuser':
 Logged into grid as zenuser

> zos jobinfo --detail instclients Jobname/Parameters    Attributes
------------------    ----------
instclients        Desc: This job installs the ZOS clients on a resource

    host           Desc: The host name of resource to install on
                   Type: String
                Default: None! Value must be specified

Description

The files that make up the Instclients job include:

instclients                                 # Total: 138 lines
|-- instclients.jdl                         #   97 lines
`-- instclients.policy                      #   41 lines

instclients.jdl

 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: instclients.jdl,v 1.4 2008/03/05 20:05:54 ray Exp $
13  # -----------------------------------------------------------------------------
14
15  """
16
17  Run install clients on a resource
18
19  Setup:
20      Before running the job, you must copy installers into DataGrid of
21      server.
22
23      >zos copy zosclients_windows_1_3_0_with_jre.exe grid:///\!instclients/
24
25  """
26  import os,time
27
28  #
29  # Add to the 'examples' group on deployment
30  #
31  if __mode__ == "deploy":
32      try:
33          jobgroupname = "examples"
34          jobgroup = getMatrix().getGroup(TYPE_JOB, jobgroupname)
35          if jobgroup == None:
36              jobgroup = getMatrix().createGroup(TYPE_JOB, jobgroupname)
37          jobgroup.addMember(__jobname__)
38      except:
39          exc_type, exc_value, exc_traceback = sys.exc_info()
40          print "Error adding %s to %s group: %s %s" % (__jobname__, jobgroupname, exc_type, exc_value)
41
42
43  class InstClients(Job):
44
45       def job_started_event(self):
46            print "Scheduling joblet"
47            self.schedule(InstClientsJoblet)
48
49
50  class InstClientsJoblet(Joblet):
51
52       def joblet_started_event(self):
53            print "Launching Installer"
54            windowsInstaller = "zosclients_windows_1_3_0_with_jre.exe"
55            linuxInstaller = "zosclients_linux_1_3_0_with_jre.sh"
56            if self.getFact("resource.os.family") == "windows":
57                 print "Downloading Windows install"
58                 dg = DataGrid()
59                 dg.copy("grid:///!instclients/" + windowsInstaller,windowsInstaller)
60
61                 print "Starting install"
62                 cmd = self.getcwd() + "/" + windowsInstaller + " -q "
63                 e = Exec()
64                 e.setCommand(cmd)
65                 e.setRunAsJobUser(False)
66                 e.writeStdoutToLog()
67                 e.writeStderrToLog()
68                 result = e.execute()
69            else:
70                 print "Downloading Linux install"
71                 dg = DataGrid()
72                 dg.copy("grid:///!instclients/" + linuxInstaller,linuxInstaller)
73
74                 print "Starting install"
75                 cmd = "chmod +x " + self.getcwd() + "/" + linuxInstaller
76                 print "cmd=%s" % (cmd)
77                 e = Exec()
78                 e.setCommand(cmd)
79                 e.setRunAsJobUser(False)
80                 e.writeStdoutToLog()
81                 e.writeStderrToLog()
82                 result = e.execute()
83
84                 cmd = self.getcwd() + "/" + linuxInstaller + " -q"
85                 print "cmd=%s" % (cmd)
86                 e = Exec()
87                 e.setRunAsJobUser(False)
88                 e.setCommand(cmd)
89                 e.writeStdoutToLog()
90                 e.writeStderrToLog()
91                 result = e.execute()
92
93            if result == 0:
94                 print "Install complete"
95            else:
96                 print "result=%d" % (result)
97

instclients.policy

 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: instclients.policy,v 1.2 2008/02/27 20:50:26 john Exp $
14   *=============================================================================
15   -->
16
17  <policy>
18
19       <jobargs>
20
21            <fact name="host"
22                  type="String"
23                  description="The host name of resource to install on"
24                   />
25
26       </jobargs>
27
28       <job>
29            <fact name="description"
30                  type="String"
31                  value="This job installs the ZOS clients on a resource" />
32       </job>
33
34       <constraint type="resource" >
35
36            <eq fact="resource.id" factvalue="jobargs.host" />
37
38       </constraint>
39
40  </policy>
41

Classes and Methods

Definitions:

Job

A representation of a running job instance.

Joblet

Defines execution on the resource.

MatrixInfo

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.

GroupInfo

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.

Exec

Used to manage command line execution on resources.

DataGrid

Provides a way to interact with the datagrid. Operations include copying files from the datagrid down to the resource for joblet usage and uploading files from a resource to the datagrid.

Job Details

The following sections describe the Instclients job:

zosadmin deploy

When jobs are deployed into the grid, they can optionally be placed in groups for organization and easy reference. In this case, the Instclients job will be added to the group named Examples, and will show up 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 Deploying a Sample System Job in the Novell ZENworks Orchestrator 1.3 Installation and Getting Started Guide.

job_started_event

When the Instclients job receives a job_started_event, it schedules a single instance of the Instclients joblet to be run (see line 32 of instclients.jdl). The resource that runs the joblet is determined from the resource constraint specified in instclients.policy, lines 12-14, and from the value for the parameter host supplied on the command line.

joblet_started_event

After the Instclients joblet is executed on a particular resource, it receives a joblet_started_event. When this happens, the Instclients joblet decides which Orchestrator Client installation file to download, and the commands to execute on the operating system by checking the value of resource.os.family (see line 40 of instclients.jdl). The resource.os.family fact does not exist in the instclients.policy file, but is instead provided by the ZENworks Orchestrator system.

After deciding which operating system the joblet is being run on, the Instaclients joblet uses the DataGrid class to download the appropriate client installation file to the current working directory of the running joblet (see lines 41-43 and 54-56 in instclients.jdl). The URL grid://!instclients/ points to a directory reserved for the joblet in the datagrid on the server.

After the client installation file has been downloaded from the server, the Instclients joblet uses the Exec class to begin the installation (see lines 46-52 and 58-75 in instclients.jdll). As indicated by lines 50, 51, 64, 65, 73 and 74, all standard out and standard err are written to the job’s log file.

To view the log file for the Instclients job after it has been run, you can execute the command

zos log instclients

For more information about using zos, see Section 7.5.2, Using the ZOSADMIN Command Line Tool. See the Exec class in Orchestrator Job Classes and JDL Syntax for more information on running commands.

NOTE:The Instclients job uses the Exec class twice when running on a Linux resource. The first command changes the mode of the installation file to be an executable, and the second runs the installation file.

Configure and Run

Execute the following commands to deploy and run instclients.job:

  1. Copy client installation files into the directory reserved for the Instclients joblet in the datagrid of the Orchestrator Server (note: replace windows with Linux*, Solaris*, etc. for your given operating system):

    zos copy zosclients_linux_1_3_0_with_jre.sh grid:///\!instclients/
    

    This command copies the file zosclients_linux_1_3_0_with_jre.sh into the datagrid job directory for instclients.

    For more information about using ZENworks Orchestrator Console to copy files, type zos copy -help.

    NOTE:Replace windows with linux, solaris, etc. for your given operating system.

  2. Deploy instclients.job into the grid by entering:

    zosadmin deploy instclients.job
    
  3. Display the list of deployed jobs by entering:

    zos joblist
    

    instclients should appear in this list.

  4. Run the job on the resource with the given host:

    zos run instclients host=my_resource_host
    

    Installs the Orchestrator client onto the resource with the host: my_resource_host.

See Also