Example- Walking multiple types of relationships for a CI instance using the CMDBGraphQuery function
Suppose that you start on a CI instance of class
A:A with instance ID 1 and walk relationships of class
A:rAB, which represents a relationship with an
A:A instance as the source and an
A:B instance as the destination. From
A:B you want to walk relationship
A:rBA, which has class
A:B as the source and class
A:A as the destination. You want to walk outward to the last level, so the value of the
numLevels argument is -1. The instances of the CI and relationship classes have no qualifications. You are retrieving all of the attributes of the relationship instances and the CI instances.
Graphically, the query you want to walk is illustrated in the following figure. As with example 1, the graph for this query can be represented either as (a) or (b). In representation (a), the class
A:A appears twice. To distinguish one instance of
A:A from the other, an
extensionId is needed. In this example, one of the instances is assigned the arbitrary
extensionId of two.
Graph of Query Example 2
queryGraph data structures for Graph of Query example 2 (a)
queryGraph data structures for Graph of Query example 2 (b)
The path taken to walk this graph is shown by the bolded relationships in the following figure. The bolded nodes are those returned in the
The expected data to be returned is:
- Six CIs. Three are instances of
A:Awith instance IDs 8, 5, and 9. Three are instances of
A:Bwith instance IDs 1, 3, and 2.
- Six relationships. Three are instances of
A:rABwith instance IDs 1, 3, and 2. Three are instances of
A:rBAwith instance IDs 1, 2, and 3.
Path walked and nodes returned by Query Example 2