プライマリ・コンテンツに移動
Oracle® Enterprise Manager Connectors統合ガイド
13c リリース2
E94901-01
目次へ移動
目次

前
前へ
次

D デフォルト・テンプレートの例

この付録に含まれる例では、チケッティング・コネクタの2つのデフォルト・テンプレートを作成する方法を示し、完成したテンプレートを示します。

次のリストは、テンプレートを作成するためのステップです。

  1. 外部のチケッティング・アプリケーションのデータを調査します。

    最初のステップでは、外部のチケッティング・アプリケーションのWebサービスを調査して、使用可能なフィールドおよびそれらのフィールドにデータがどのように表示されるかを確認します。

    WebサービスWSDLの調査では、作成リクエストのルート要素はcreateRequestで、更新リクエストのルート要素はupdateRequestであることを示しています。ネームスペースは両方ともhttp://samplecompany.comです。WSDLは、作成には4つの必須フィールドがあることも示しています。これらのフィールドは、summarydescriptionseverityおよびassignment groupです。severityフィールドには、1から5の数値を指定する必要があります。1が最高で、5が最低です。作成リクエストでは、必須フィールドにのみ値を入力することを決定しました。

    更新の場合は、identifierフィールドと履歴ログ・フィールドのみが必須です。更新リクエストでは、これらのフィールドをseverityフィールドとともに指定する予定です。

  2. Enterprise Managerのデータを調査します。

    チケットの作成/更新に必要なデータを理解した後は、Enterprise Managerで使用可能なデータとそのデータが格納されている場所を把握する必要があります。データの調査では、必要なデータはすべてSystemAttributes要素に配置されていることが示されました。サマリー情報を保持するSummary要素があり、使用可能なSeverityCodeフィールドもあります。SystemAttributes要素には、チケットの説明に表示できるターゲット情報も含まれています。一部のチケット・フィールドは、Enterprise Managerのインシデント・データに十分な情報がないため、ハードコードする必要があります。

  3. テンプレートの数およびそれぞれのマッピングを決定します。

    コネクタに対して2つのデフォルト・テンプレートを作成することを決定しました。一方のテンプレートはチケットをオープンしたままにして、Enterprise Managerでインシデントがクリアされるたびに履歴ログを更新し、他方のテンプレートはチケットをクローズします。

    チケットを作成するためのマッピングは両方のテンプレートとも同じです。次のリストは、作成操作に対して識別されたマッピングです。

    • サマリーはSystemAttributes/Summaryフィールドの内容に設定されます。

    • 説明はSystemAttributes/Summaryフィールドとそれに続くターゲット情報の内容に設定されます。ターゲット情報はSystemAttributes/SourceInfo/TargetInfo要素に配置されます。含まれるターゲット・フィールドはTargetNameTargetTypeおよびTargetURLです。

    • 重大度はSystemAttributes/SeverityCodeフィールドの内容に基づいて設定されます。フィールドがFATALに設定されている場合、重大度は1に設定されます。フィールドがCRITICALに設定されている場合、重大度は2に設定されます。フィールドがWARNINGに設定されている場合、重大度は3に設定されます。他のすべての値については、重大度が5に設定されます。

    • 割当グループはTriageチームにハードコードされます。

    通常の更新(クリアされていない)のマッピングは両方のテンプレートとも同じになります。次のリストは、通常の更新操作に対して識別されたマッピングです。

    • 識別子はTicketIDフィールドの内容に設定されます。

    • 重大度はSystemAttributes/SeverityCodeフィールドの内容に基づいて設定されます。ここで使用されるマッピングは、作成操作と同じになります。

    • 履歴エントリはSystemAttributes/Severityフィールドに基づいて設定されます。履歴エントリは、"Updates from Enterprise Manager.The severity is now set to"の後にSystemAttributes/Severityフィールドが続く内容となります。

    クローズ操作のマッピングはテンプレートに応じて異なります。チケットをクローズしないテンプレートは、通常の更新と同じマッピングを使用します。チケットをクローズするテンプレートのマッピングは次のとおりです。

    • 識別子はTicketIDフィールドの内容に設定されます。

    • ステータスはCLOSEDに設定されます。

    • 履歴エントリは"Corresponding incident in Enterprise Manager has been cleared"に設定されます。

  4. 最初のテンプレートを作成します。

    チケットをクローズしないテンプレートは実装がより簡単であるため、最初にこれを操作します。

    例1-6からテンプレート・スケルトンのコンテンツをエディタにコピーすることでプロセスを開始します。次に、「作成マッピング」および「更新マッピング」に示されているように、createリクエストおよびupdateリクエストのマッピングを作成します。

    「完成した最初のテンプレートの例」は、スケルトン・テンプレートにマッピングを追加した後のテンプレートを示しています。この項には、「サンプル・インシデント・データ」にあるサンプル・トランザクションを使用したテストの結果も含まれています。最初のテンプレートを十分にテストしてから、他のテンプレートのベースラインとして使用することが重要です。

  5. 2番目のテンプレートを作成します。

    ほとんどの作業は、最初のテンプレートの作成時に実行済です。2番目のテンプレートを作成するために、MyApp_Default_Incident.xslファイルのコピーを作成し、コピーしたファイルをMyApp_Default_Incident_AutoClose.xslという名前に変更します。

    2つのテンプレートの唯一の違いは、クローズ操作のためのマッピングです。最初にマップする必要があるフィールドはIdentifierです。次に、フィールドのマッピングを示します。

    <Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>
    

    次に設定するフィールドはStatusフィールドです。これはCLOSEDにハードコードされます。

    <Status>CLOSED</Status>
    

    最後に設定するフィールドはHistoryEntryフィールドです。これはEnterprise Managerのインシデントがクリアされたことを示すようにハードコードされます。

    <HistoryEntry>Corresponding incident in Enterprise Manager has been cleared.</HistoryEntry>
    

    ここでは、更新がクローズか通常の更新かどうかを特定するチェックが追加されています。SeverityCodeがCLEARに設定されている場合はチケットのクローズが必要であると認識され、それ以外の場合は通常の更新として処理されます。次に、追加されたチェックを示します。

    <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CLEAR'">
    

    「完成した2番目のテンプレートの例」は、チケットのクローズを処理するためのマッピングを追加した後のテンプレートを示しています。この項には、「サンプル・インシデント・データ」にあるサンプル・クローズ・トランザクションを使用したテストの結果も含まれています。

D.1 作成マッピング

作成する最初のマッピングは作成リクエスト用です。一度に1つのフィールドに対して必要な変換ロジックを識別します。最初のフィールドはSummaryフィールドです。次に、このフィールドをインシデントのSummaryフィールドにマップするのに必要な変換ロジックを示します。

<Summary><xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/></Summary>

次にマップするフィールドはDescriptionフィールドです。このフィールドは、サマリーとそれに続くターゲット情報で構成されます。次に、Descriptionフィールドのマッピングを示します。

<Description>Incident created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/>
Target information:
      Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType"/>
      Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName"/>
      Target URL: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/>
</Description>

次にマップするフィールドはSeverityフィールドです。このフィールドは作成リクエストと更新リクエストに対してマップされるため、多少異なる処理が行われます。マップされた重大度の値を保持するために変数が作成され、その変数が両方のマッピングに使用されます。この方法によって、マッピングが変更された場合に変更が1箇所のみで済みます。

<xsl:variable name="sev">
  <xsl:choose>
    <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'">1</xsl:when>
    <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'">2</xsl:when>
    <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'">3</xsl:when>
    <xsl:otherwise>5</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<Severity><xsl:value-of select="$sev"/></Severity>

最後にマップするフィールドはAssigmentGroupフィールドです。インシデントには、外部のチケッティング・アプリケーションの適切なグループを判断するために使用できる情報がないため、このフィールドはハードコードされます。

<AssignmentGroup>Triage</AssignmentGroup>

D.2 更新マッピング

最初にマップするフィールドはIdentifierフィールドです。このフィールドはインシデントのTicketIDフィールドに設定されます。次に、このフィールドのマッピングを示します。

<Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>

次にマップするフィールドはSeverityフィールドです。sev変数は以前に作成されているため、必要なのはフィールドを変数の内容に設定することです。

<Severity><xsl:value-of select="$sev"/></Severity>

最後のフィールドはHistoryEntryフィールドです。SeverityCodeのかわりにSeverityが使用されていることに注意してください。SeverityCodeフィールドは重大度値の内部表現であり、固定値です。インシデント・データのSeverityフィールドはロケール固有であるため、このフィールドの値はロケールによって異なります。SeverityCodeフィールドは特定の重大度値を調べる際に使用し、Severityフィールドは重大度を表示するときに使用する必要があります。

<HistoryEntry>Updates from Enterprise Manager. The severity is now set to <xsl:value-of select="emcf:SystemAttributes/emcf:Severity"/></HistoryEntry>

D.3 完成したテンプレート

次の例は、完成したテンプレートを示しています。

D.3.1 完成した最初のテンプレートの例

次に、この項で前述したマッピングを使用して完成したテンプレートを示します。テンプレートのファイル名はMyApp_Default_Incident.xslです。

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" 
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:emcf="http://xmlns.oracle.com/sysman/connector">
 
  <xsl:template match="emcf:EMIncident">
    <xsl:variable name="sev">
      <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'">1</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'">2</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'">3</xsl:when>
        <xsl:otherwise>5</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
 
    <xsl:choose>
      <xsl:when test="normalize-space(emcf:TicketID) = ''">
 
        <!-- CREATE Request -->
        <createRequest xmlns="http://samplecompany.com">
          <Summary><xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/></Summary>
          <Description>Incident created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/>
Target information:
      Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType"/>
      Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName"/>
      Target URL: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/></Description>
          <Severity><xsl:value-of select="$sev"/></Severity>
          <AssignmentGroup>Triage</AssignmentGroup>
        </createRequest>
 
      </xsl:when>
      <xsl:otherwise>
 
        <!-- UPDATE Request -->
        <updateRequest xmlns="http://samplecompany.com">
          <Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>
          <Severity><xsl:value-of select="$sev"/></Severity>
          <HistoryEntry>Updates from Enterprise Manager. The severity is now set to <xsl:value-of select="emcf:SystemAttributes/emcf:Severity"/></HistoryEntry>
        </updateRequest>
 
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

次に、「サンプル・インシデント・データ」の「サンプル作成トランザクション」データを入力として使用したテンプレートからの出力を示します。

<?xml version="1.0" encoding="UTF-8"?>
<createRequest xmlns="http://samplecompany.com" xmlns:emcf="http://xmlns.mycompany.com/sysman/connector">
   <Summary>Memory Utilization is 70.518%, crossed warning (20) or critical (30) threshold.</Summary>
   <Description>Incident created in Enterprise Manager: Memory Utilization is 70.518%, crossed warning (20) or critical (30) threshold.
Target information:
      Target Type: host
      Target Name: target1.mycompany.com
      Target URL: https://mytarget1.mycompany.com:5416/em/redirect?pageType=TARGET_HOMEPAGE&amp;targetName=target1.mycompany.com&amp;targetType=host</Description>
   <Severity>2</Severity>
   <AssignmentGroup>Triage</AssignmentGroup>
</createRequest>

次に、「サンプル・インシデント・データ」の「サンプル更新トランザクション」データを入力として使用したテンプレートからの出力を示します。

<?xml version="1.0" encoding="UTF-8"?>
<updateRequest xmlns="http://samplecompany.com" xmlns:emcf="http://xml.mycompany.com/sysman/connector">
   <Identifier>CASD-000002 (cr:0000002)</Identifier>
   <Severity>3</Severity>
   <HistoryEntry>Updates from Enterprise Manager. The severity is now set to Warning</HistoryEntry>
</updateRequest>

D.3.2 完成した2番目のテンプレートの例

次に、完成した2番目のテンプレートを示します。Closedセクションが追加されていることに注意してください。

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" 
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:emcf="http://xmlns.oracle.com/sysman/connector">
 
  <xsl:template match="emcf:EMIncident">
    <xsl:variable name="sev">
      <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'">1</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'">2</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'">3</xsl:when>
        <xsl:otherwise>5</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
 
    <xsl:choose>
      <xsl:when test="normalize-space(emcf:TicketID) = ''">
 
        <!-- CREATE Request -->
        <createRequest xmlns="http://samplecompany.com">
          <Summary><xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/></Summary>
          <Description>Incident created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/>
Target information:
      Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType"/>
      Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName"/>
      Target URL: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/></Description>
          <Severity><xsl:value-of select="$sev"/></Severity>
          <AssignmentGroup>Triage</AssignmentGroup>
        </createRequest>
 
      </xsl:when>
      <xsl:otherwise>
 
       <!-- An update is being performed. Need to determine if this is a close or a normal update. -->
 
        <xsl:choose>
          <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CLEAR'">
 
            <!-- CLOSE Request -->
            <updateRequest xmlns="http://samplecompany.com">
              <Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>
              <Status>CLOSED</Status>
              <HistoryEntry>Corresponding incident in Enterprise Manager has been cleared.</HistoryEntry>
            </updateRequest>
 
          </xsl:when>
          <xsl:otherwise>
 
            <!-- Normal UPDATE Request -->
            <updateRequest xmlns="http://samplecompany.com">
              <Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>
              <Severity><xsl:value-of select="$sev"/></Severity>
              <HistoryEntry>Updates from Enterprise Manager. The severity is now set to <xsl:value-of select="emcf:SystemAttributes/emcf:Severity"/></HistoryEntry>
            </updateRequest>
 
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

次に、「サンプル・インシデント・データ」の「サンプル・クローズ・トランザクション」データを入力として使用したテンプレートからの出力を示します。

<?xml version="1.0" encoding="UTF-8"?>
<updateRequest xmlns="http://samplecompany.com" xmlns:emcf="http://xmlns.oracle.com/sysman/connector">
   <Identifier>CASD-000002 (cr:0000002)</Identifier>
   <Status>CLOSED</Status>
   <HistoryEntry>Corresponding incident in Enterprise Manager has been cleared.</HistoryEntry>
</updateRequest>