Creating Queues and Groups Using Type Projections

Creating Queues and Groups Using Type Projections

  • Comments 3
  • Likes

Update: You can do this in the console in SCSM 2010 SP1 now.

Background information for this post:  Groups are typically collections of Configuration Items (although technically it can be groups of any kind of object).  Queues are collections of a certain kind of work item – like a queue of incidents.  Groups and Queues can be based on dynamic inclusion criteria like ‘All Windows Computers where the Domain property contains ‘Redmond’’.  Groups (only) can also have static membership like ‘include Computer1, Computer2, Computer3…  Groups (only) can also exclude objects and include other Groups.  Groups and Queues are used for role based security scoping, notification subscription criteria, and for report filtering (and eventually for view criteria – that was unfortunately cut for SCSM 2010 due to lack of time).   The idea is to define a group of things, use it many places, and any time you need to change the definition of that group of things you can do it in one place and have it immediately apply to all the places where that definition is being used.

More information on type projections:

http://blogs.technet.com/b/servicemanager/archive/2010/02/02/creating-views-that-use-related-property-criteria-type-projections-software-views-example.aspx

 

In the Group and Queue wizard you can create criteria based on properties of the selected Configuration Item or Work Item class like this:

image

We are often asked how you can create groups or queues using properties of related objects in the criteria.  Here are just a few examples we’ve heard:

  • Windows Computers where the Operating System Version is ‘Windows 7’
  • Windows Computers where the Operating System is a Server vs. a Client OS
  • Incidents (or any other work item for that matter) where the affected Service (or any other CI) is ‘some service’
  • Incidents where the affected user is a VIP
  • Incidents where the affected user is in company ‘Contoso’
  • Incidents where the assigned to user is in company ‘Contoso’

And on and on…

You can’t do this in the wizard in the console unfortunately, but you can do this in the MP XML if you know what you are doing.  That’s what this blog post is about.  For the purposes of this blog post we’ll implement the three highlighted examples from above.  From there, you’ll get the idea and can really do anything.

First of all you need to define the Group or Queue as a new singleton ClassType.  Groups should derive from Microsoft.SystemCenter.ConfigItemGroup and Queues should derive from System.WorkItemGroup.

image

Next, for Queues (only) you’ll need to define a RelationshipType which tells Service Manager what kind of work items will be contained in the Queue.  The RelationshipType should derive from System.WorkItemGroupContainsWorkItems.  The Source Type attribute should point to the ClassType ID from above.  The Target Type attribute should point to the Work Item ClassType that you will be containing.

image

Next you need to define a Discovery for each  Group\Queue. 

  • The Target attribute should point at the ClassType of the Queue/Group from above. 
  • The DiscoveryRelationship TypeID attribute should point to the RelationshipType ID created above for queues.  For groups it should always point to Microsoft.SystemCenter.InstanceGroupContainsEntities. 
  • The GroupInstanceId MPElement Name should be the same as the ClassType ID from above. 
  • The TypeProjection MPElement Name should point to the TypeProjection ID you are going to query over.
  • The MonitoringClass MPElement Name should be the ClassType ID of the objects you are going to include in the group
  • The RelationshipClass MPElement Name should be the same as the DiscoveryRelationship TypeID.

image

Next you just need to specify the criteria.  Let’s take this apart a piece at a time…

First we have a simple expression which is just going to look at a certain property of a related object and compare it using a LIKE operator and look for a certain string to be somewhere in the property value.  It’s the equivalent of doing a T-SQL Like %<search term>% query in SQL Server.  The tricky bit here is the Property expression syntax so we’ll take this one piece at a time…

First – always start with $Context/ …

$Context/

The specify the RelationshipType ID that you want to traverse over…

Path[Relationship='Windows!Microsoft.Windows.ComputerHostsOperatingSystem'

Then, optionally specify if you only want to look at objects of a specific class by specifying a TypeConstraint…

TypeConstraint='Windows!Microsoft.Windows.OperatingSystem']/

The specify which class the property you want to look at is defined on…

Property[Type='Windows!Microsoft.Windows.OperatingSystem']/

And lastly specify the property ID…

OSVersionDisplayName$ 

So – it looks like this when completed:

$Context/Path[Relationship='Windows!Microsoft.Windows.ComputerHostsOperatingSystem' TypeConstraint='Windows!Microsoft.Windows.OperatingSystem']/Property[Type='Windows!Microsoft.Windows.OperatingSystem']/OSVersionDisplayName$

 

For more information on constructing Criteria XML please see this blog post:

http://blogs.technet.com/b/servicemanager/archive/2010/04/26/querying-for-objects-using-object-criteria-object-query-criteria-tool-example.aspx

Here is the complete management pack with all of these examples in it:

http://cid-17faa48294add53f.skydrive.live.com/self.aspx/.Public/Examples/QueuesAndGroupsWithTypeProjections.xml

 

Important Note:  Queues/Groups created in this way cannot be edited in the SCSM console in any way.  Even editing it to change the name or something like that will cause the SCSM console to remove the criteria part of the queue/group definition.  All edits to groups/queues that use this kind of criteria must be done in XML.  To ensure that users dont try to edit these queues/groups in the console and also to ensure upgradeability from one version of the MP to the next you can seal the MP following these instructions:

http://blogs.technet.com/servicemanager/archive/2009/12/25/sealing-management-packs.aspx

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Hi Travis,

    Can we create Queues based on your example on SP1? Or still we need to stick on the XML?

    Like: Incidents where the affected user is in company ‘Contoso’

  • @Ozge -

    You can do this in the UI in SP1 now.

  • Is it possible to create the queue for the items assigned to [me]