5.6 Custom Template Examples

This section provides walk-through examples of what is required to create custom templates. The first example is a simple case of changing values for fields that are already specified in the default templates. The second example is more involved, and includes populating fields that are not already in the default templates.

5.6.1 Example 1

In this example, the customer has determined that the default mappings do not function for their environment. They have created a new assignment group named "Tier 1 Support" that should handle all incidents that Enterprise Manager reports. They are running version 9 in their environment and would like to close the incidents in Service Manager after the incidents have cleared in Enterprise Manager. They have also created a temporary directory on the OMS server system at /home/oracle/custom_templates to hold the templates.

To create a custom template that handles the customer's requirements:

  1. Navigate to the Management Connector Updates page and export the HPSM 9 Connector.

  2. Copy the first EM CLI command listed in the Export Steps window for later use:

    emcli export_update -id=DD4E9161C5E7129F9641447FB4F0497B -omslocal -dir=<dirname>
    
  3. Open a command window on the OMS server system and change the working directory to the temporary directory:

    cd /home/oracle/custom_templates
    
  4. Log into EM CLI:

    emcli login -username=sysman
    
  5. Run the EM CLI command from step 1 to export the .zip file to the temporary directory.

    emcli export_update -id=DD4E9161C5E7129F9641447FB4F0497B -omslocal -dir=/home/oracle/custom_templates
    
  6. Extract the connector .jar file from the .zip file:

    unzip *.zip archives/*connector.jar
    
  7. Extract the template files from the .jar file:

    $JAVA_HOME/bin/jar xf archives/*.jar templates
    
  8. Copy the default template to a custom template file for modification:

    cd templates
    
    cp ServiceManager_9_Default_Incident_AutoClose.xsl Tier1_Support_AutoClose.xsl
    
  9. Open the custom template file with a text editor and make the modifications shown below to the AssignmentGroup node.

    Before changes

    <m:AssignmentGroup>Service Desk</m:AssignmentGroup>
    

    After changes

    <m:AssignmentGroup>Tier1 Support</m:AssignmentGroup>
    

    Since this is a trivial change, you can skip testing.

  10. At the OMS server system, run the following command to register your new custom template:

    emctl register_template connector
    -t /home/oracle/custom_templates/templates/Tier1_Support_AutoClose.xsl
    -repos_pwd sysmanpass
    -cname "HPSM 9"
    -iname "Tier1SupportAutoClose"
    -tname "Tier1 Support AutoClose"
    -ttype 2
    -d "Template to set assignment group to Tier1 Support"
    

5.6.2 Example 2

In this example, the customer would like to populate the following additional fields:

  • Affected Item — This field will be populated by the Target Host information from the Target Properties.

  • Location — This field will be populated by the Location information from the Target Properties.

  • Target URL — This a new custom field that was added to their web service to hold the Target URL from the Enterprise Manager incident.

They are running version 9 in their environment, and would like to close the incidents in Service Manager after the incidents have cleared in Enterprise Manager. They have also created a temporary directory on the OMS server system at /home/oracle/custom_templates to hold the templates.

To create a custom template that handles their requirements:

  1. Navigate to the Management Connector Updates page and export the HPSM 9 Connector.

  2. Copy the first EM CLI command listed in the Export Steps window for later use:

    emcli export_update -id=C5289206C5A5A84AF82C49821C8F2931 -omslocal -dir=<dirname>
    
  3. Open a command window on the OMS server system and change the working directory to the temporary directory:

    cd /home/oracle/custom_templates
    
  4. Log into EM CLI:

    emcli login -username=sysman
    
  5. Run the EM CLI command from step 1 to export the .zip file to the temporary directory.

    emcli export_update -id=C5289206C5A5A84AF82C49821C8F2931 -omslocal -dir=/home/oracle/custom_templates
    
  6. Extract the connector .jar file from the .zip file:

    unzip *.zip archives/*connector.jar
    
  7. Extract the template files from the .jar file:

    $JAVA_HOME/bin/jar xf archives/*.jar templates
    
  8. Copy the default template to a custom template file for modification:

    cd templates
    
    cp ServiceManager_9_Default_Incident_AutoClose.xsl Target_Info_AutoClose.xsl
    
  9. Open the custom template file with a text editor and make the modifications shown below. The changes are shown in bold. Note that the new fields were added in the correct sequence as defined in the WSDL.

    Before changes

    <m:AssignmentGroup>Service Desk</m:AssignmentGroup>
     
    . . .
     
    <m:Impact>1</m:Impact>
     
    . . .
     
    <m:OracleConnectorId><xsl:value-of select="ns0:ConnectorGUID"/></m:OracleConnectorId>
    

    After changes

    <m:AssignmentGroup>Service Desk</m:PrimaryAssignmentGroup>
    <xsl:for-each select="ns0:SystemAttributes/ns0:SourceInfo/ns0:TargetInfo/ns0:TargetProperty">
        <xsl:if test="./ns0:Name = 'Target_Host'">
         <m:AffectedItem><xsl:value-of select="./ns0:Value"/></m:AffectedItem>
       </xsl:if>
    </xsl:for-each>
     
    . . .
     
    <m:Impact>1</m:Impact>
    <xsl:for-each select="ns0:SystemAttributes/ns0:SourceInfo/ns0:TargetInfo/ns0:TargetProperty">
        <xsl:if test="./ns0:Name = 'Location'">
            <m:Location><xsl:value-of select="./ns0:Value"/></m:Location>
        </xsl:if>
    </xsl:for-each>
     
    . . .
     
    <m:OracleConnectorId><xsl:value-of select="ns0:ConnectorGUID"/></m:OracleConnectorId>
    <m:TargetURL><xsl:value-of 
    select="ns0:SystemAttributes/ns0:SourceInfo/ns0:TargetInfo/ns0:TargetURL"/></m:TargetURL>
    
  10. To set up for testing, create the create.xml file and open the file in a text editor.

  11. Copy the contents of the XML document in the "Create Example" section of Enterprise Manager Incident Examples into the create.xml file and save it.

  12. Test the new template using a utility that performs XSLT translations using the create.xml file as the input XML document.

  13. Examine the output XML document and verify that the results are correct.

    Note:

    You can also use an XML client to send the XML output document to the Management Server web service to verify that it is a format accepted by Service Manager.

  14. If you encounter problems with the XML document, make any necessary corrections and repeat steps 12 and 13.

  15. At the OMS server system, run the following command to register your new custom template:

    emctl register_template connector
    -t /home/oracle/custom_templates/templates/Target_Info_AutoClose.xsl
    -repos_pwd sysmanpass
    -cname "HPSM 9"
    -iname "TargetInfoAutoClose"
    -tname "Target Info AutoClose"
    -ttype 2
    -d "Template to set target fields"