Create a relationship and a reference

As part of creating or modifying a discovery pattern, you can use the Relation and/or Reference condition to create relationships and references between CIs a pattern discovers. This operation is relevant for both infrastructure and application patterns that Discovery uses for horizontal discovery.

Before you begin

Decide on the nature of relationship or reference that you are going to create.

The CI relationship you define in the pattern must comply with the model you have created:
  1. Check if the CI is dependent: The system uses the identification rules to identify the CI independently of other CIs. Refer to Create or edit a CI identification rule.
  2. If the CI is dependent, check its dependent relationship rules which define dependency structure of the CI types and the relationship types in these service definitions. For example, you can discover a load balancer pool with pool members belonging to it. To correctly reflect the type of relationship between these two CIs, create a containment rule, which defines the load balancer pool as the owner of pool members: Runs on::Runs. For more information, refer to Dependent relationship rules.
    Figure 1. Example of a dependent rule for Load Balancer Pool Member

    Checking hosting rules in the Metadata Editor

    For independent CI types without dependent relationship rules define for them, you can define any relationship.

  3. (Optional for application patterns used for horizontal discovery) Make sure that the data discovered using this pattern is saved as a table using standard parsing operations.

  4. (Optional for creating a reference) Navigate to the relevant table definitions for the parent and the child CIs and choose the field to use as a reference field.

  5. Navigate to the relevant pattern step:

    1. On the pattern form, select the relevant identification section.
    2. Select the relevant step or create a pattern step by clicking .

Basic knowledge of programming is desirable.

Role required: pd_admin

About this task

Discovery use some patterns to discover a CI with all its related CIs. CIs can have different relationships with each other. Dependent relationship rules describe relationships between CIs. The identification engine uses these Dependent relationship rules to uniquely identify CIs and determine if a specific CI already exists in the CMDB or must be added to it.

When you create a relationship, the system uses the parent CI and the child CI tables and creates a third table with data on the relationship between the parent and child CIs.

In addition to a relationship between CIs, you can create a reference connection between them. If a reference exists, then information about referenced child CIs appears at the bottom of the parent CI form. For example, all load balancer pool members appear on the form of the load balancer pool, which owns these members.


Referenced load balancer services appear on a load balancer form

Procedure

  1. Add related CIs to the main CI pattern to be able to view and use attributes of related CI types.
  2. Select Create Relation/Reference from the Operation list.
  3. Add the related CI type to this pattern as described in Add related CIs to the main CI pattern.
  4. Complete the form using the fields in the table.
    Table 1. Relation and/or Reference operation fields
    Field Description
    Parent Table Enter the name of the table for the CI that you want to use as a parent CI in the relation. For example, cmdb_ci_lb_pool for the load balancer pool CI.
    Child Table Enter the name of the table for the CI that you want to use as a child CI in the relation. For example, cmdb_ci_lb_pool_member for the load balancer pool member, which the load balancer pool owns.
    Result Table Enter the name for the new table to store information about relations and references between CIs, resulting from this operation.
    Relation Type Select the type of relationship between CIs from the specified target tables. The part in the type name before the separator (::) refers to the parent CI and the second part, after the separator (::), to the child CI. For example, in the Owns::Owned by option:
    • "Owns" indicates that a load balancer pool [cmdb_ci_lb_pool] owns a load balancer pool member [cmdb_ci_lb_pool_member].
    • "Owned by" indicates that a load balancer pool member [cmdb_ci_lb_pool_member] is owned by a load balancer pool [cmdb_ci_lb_pool].
    Warning: Make sure to choose the right option among relation types using the same words, like Used by::Uses and Uses::Used by.
    Reference Select this check box to create a reference between the parent and the child CIs.
    Direction (Only if Reference is selected) Select the direction of the reference:
    • Parent to Child to display the parent CI on the child CI form. For example, the load balancer pool member form displays load balancer pool, which owns this pool member.
    • Child to Parent to display child CIs on the parent CI form. For example, the load balancer pool form displays load balancer pool members this pool owns.
    Column Name (Only if Reference is selected) Enter the name of the field in the child CI table that the system uses to create the reference. For example, load_balancer.
    Creation Criteria Select the criteria used to create the relation and/or reference:
    • All
      The system creates a relationship or reference without any additional criteria.
    • Field matching
      The system creates the relationship or reference only if the value in the specified field in a parent CI matches the value of the specified field in a child CI.
    • Condition
      The system creates the relationship or reference only if the specified criteria is matched.
    Parent table field (Only if Field matching is selected) Enter the field from the parent table to compare.

    You can use variables including values from tabular variables as described in Enter values and variables in patterns.

    Child table field (Only if Field matching is selected) Enter the field from the child table to compare.
    Unmatched values Operation for values in the two tables that do not match. You can keep or remove unmatched values.
  5. If you selected Condition from Creation Criteria, define this condition:
    1. In the first condition field, enter the required value.
    2. In the first condition field, enter the required value.
      For example, enter the actual string or a variable name.

      Define precondition criteria.
    3. Select an operator from the list.
      If you select Is Empty, the second field is rendered irrelevant and disappears.
    4. To add more conditions, click the plus icon and define the criteria.
    5. If you create multiple conditions, define if this pattern must meet all or any of them: From the Meet list, select All or Any.
  6. If in Debug mode, test the step by clicking Test and checking that the operation brings the result you expected.

Example

Use the Relation/Reference command to create the Owns::Owned by relation between a load balancer pool and a load balancer pool member. You also create a reference from a load balancer pool member to the load balancer pool.

Using Relation/Reference operation to create relation between a load balancer pool and a load balancer pool member.

What to do next