Share via


Management Pack Service Model Exercise #3 - Creating a Containment Relationship


Overview

The following procedures show how to create containment relationships using both the Operations Manager 2007 Authoring Console and Visual Studio Authoring Extensions.  This exercise is part of the System Center Operations Manager Management Pack Authoring Center.

Product Versions

This exercise applies to the following products:

  • System Center Operations Manager 2007 R2
  • System Center 2012 Operations Manager
  • System Center 2012 Operations Manager SP1

Prerequisites

Before you perform this procedure, you must first complete the following prerequisite procedures:

Revisions

The Microsoft System Center team has validated this procedure as of the original version.  We will continue to review any changes and periodically provide validations on later revisions as they are made.  Please feel free to make any corrections or additions to this procedure that you think would assist other users

Sample Code

A sample of the completed code for each exercise is available in the TechNet Gallery.  There is a separate sample for each exercise that includes the management pack completed at the end of that exercise and each preceding exercise.  This strategy allows you to work through each exercise in order and then compare your results.  For VSAE, this also includes the Visual Studio solution. 

Details

The relationships created in the following procedures have these characteristics.

  • Relationship between MyHealthRollup group class and MyComputerRole1 class. This supports a health rollup of all instances of MyComputerRole1.
  • Relationship between MyComputerRole2 and MyComputerRole1. This supports a health dependency of MyComputerRole2 on MyComputerRole1.

Containment relationships do not have to be created for Instance Groups or Computer Groups, because the required relationships are already defined by the classes on which these classes are based.


Authoring Console Procedure

Creating a containment relationship for a health rollup1

  1. In the Authoring console, select Service Model, and then select Relationships.
  2. Right-click in the Relationships pane, select New, and then select Containment Relationship.
  3. On the General tab, do the following:
    1. In the ID box, type MyMP.MyHealthRollupContainsMyComputerRole1.
    2. In the Display Name box, type My Health Rollup Contains My Computer Role 1.
    3. Click Next.
  4. On the Source and Target page, do the following:
    1. In the Class ID (Source) box, select MyMP.MyHealthRollup.
    2. In the Class ID (Target) box, select MyMP.MyComputerRole1.
    3. Click Finish.
  5. Select File, and then click Save.

Creating containment relationship for dependency between two classes

  1. In the Authoring console, select Service Model, and then select Relationships.
  2. Right-click in the Relationships pane, select New, and then select Containment Relationship.
  3. On the General page, do the following:
    1. In the ID box, type MyMP.MyComputerRole2ContainsMyComputerRole1.
    2. In the Display Name box, type My Computer Role 2 Contains My Computer Role 1.
    3. Click Next.
  4. On the Source and Target page, do the following:
    1. In the Class ID (Source) box, select MyMP.MyComputerRole2.
    2. In the Class ID (Target) box, select MyMP.MyComputerRole1.
    3. Click Finish.
  5. Select File, and then click Save.

Visual Studio Authoring Extensions Procedure

Creating a containment relationship for a health rollup

  1. Right click the name of the solution and select Add and then New Item

  2. Select Relationship.

  3. In the Name box, type Relationships.mpx and click Add.

  4. Remove the comments from the Relationships.mpx file.

  5. Replace the RelationshipType entry with the following XML. This creates the relationship between the Health Rollup and Computer Role 1 classes.

    <RelationshipType
      ID="MyMP.MyHealthRollupContainsMyComputerRole1"
      Base="System!System.Containment"
      Abstract="false"
      Accessibility="Internal">
      <Source ID="Source" Type="MyMP.MyHealthRollup"/>
      <Target ID="Target" Type="MyMP.MyComputerRole1"/>
    </RelationshipType>
    
  6. Replace the DisplayString entry with the following XML. This creates the display string for the Computer Role base abstract class.

    <DisplayString ElementID="MyMP.MyHealthRollupContainsMyComputerRole1">
      <Name>My Health Rollup Contains My Computer Role 1</Name>
      <Description></Description>
    </DisplayString>
    
  7. Select File, and then click Save Relationships.mpx.

  8. Select Build and then Build Solution.

  9. Ensure that you don't receive any errors.

Creating containment relationship for dependency between two classes

  1. In Relationships.mpx, add the following XML after the RelationshipType definition for MyMP.MyHealthRollupContainsMyComputerRole1. This creates the relationship between the Computer Role classes.

    <RelationshipType
      ID="MyMP.MyComputerRole2ContainsMyComputerRole1"
      Base="System!System.Containment"
      Abstract="false"
      Accessibility="Internal">
      <Source ID="Source" Type="MyMP.MyComputerRole2"/>
      <Target ID="Target" Type="MyMP.MyComputerRole1"/>
    </RelationshipType>
    
  2. Replace the DisplayString entry with the following XML. This creates the display string for the Computer Role base abstract class.

    <DisplayString ElementID="MyMP.MyComputerRole2ContainsMyComputerRole1">
      <Name>My Computer Role 2 Contains My Computer Role 1</Name>
      <Description></Description>
    </DisplayString>
    
  3. Select File, and then click Save Relationships.mpx.

  4. Select Build and then Build Solution.

  5. Ensure that you don't receive any errors.

See Also