R12.1-2025July30
Dependency Pattern

Dependency pattern enhances the ability to parse complex, multi-layered Config-lets for golden configuration checks. In the dependency pattern, the parser results of different patterns can be merged during the parsing process to obtain the desired output, which is a table variable constructed from all the variables in all the level patterns.

Level in Dependency Pattern

A level in dependency pattern contains a predefined single-variable pattern or paragraph pattern. A dependency pattern includes one or more levels that are automatically named Level 1, Level 2, and so on. The output of the parser at one level will be merged with that from previous levels to enrich the parser's outputs.

Define Dependency Pattern

Follow the steps below to define a dependency pattern.

  1. To select a dependency pattern, click New PatternAdvanced > Dependency

  2. Define Level 1: Select a predefined pattern as the Level 1 pattern. This pattern serves as the base dependency and is read-only.
  3. Define more Levels: To define additional levels, select Define More Levels. The additional levels will follow the rules outlined below. 
    • You can refresh or delete the line pattern defined for each level. 
    • A pattern that is already selected for a level is dimmed and cannot be reused in another level. 
    • If the added level pattern contains local scopes, those scopes will not appear in the Dependency pattern. 
    • A Parent pattern and its sub-pattern can be independently selected as Levels in the Dependency pattern.
  1. Define Replace: Replace constant text in all the line patterns of the current level pattern with a variable defined in previous levels. When Replace works, the constant texts in levels will be replaced by the level creation time, which means the constant texts in levels created earlier will be replaced first. 
    1. Manually enter a variable or select one by clicking the icon to make a replacement. The selected variable must be defined at a previous level.
    2. Add the prefix and suffix to make the precise replacement.
    3. You can define multiple Replaces for a single level by clicking the  icon.
    4. You can remove Replace by clicking the icon.

Example of How to Define Dependency Pattern

In this example, define a dependency pattern to parse all the related configurations of each route OSPF instance, including the OSPF config, route map config, and prefix list config.

Prerequisites: Before defining a dependency pattern, define some single-variable patterns or paragraph patterns in the current parser; these patterns can be selected as Level.

  1. Define a paragraph pattern L1_ospf as below.
    • Parser variable $int: ospf_id by ID line.
    • Parse variable $route_map_id by Var Line 1.
    • Parser variable $ospf_config by Parse Lines > The line of variable function using the variable $ospf_id.
    • Add End of Paragraph to limit the parse scope.
  1. Define a paragraph pattern L2_route_map as below:
  • Parser variable $rou_map, then define an enumeration (B2O) for the variable in the ID Line.
  • Parse variable $prefix_list by Var Line 1.
  • Parse variable $rout_config by Parse Lines > The Line between variables function using existing variables $rout_map and $prefix_list.
  1. Define a single-variable pattern L3_prefix: Parse variable $prefix_config by the Parse Lines > The line contains keyword function.

Follow the steps below to define a dependency pattern. 

  1. Click +New Pattern > AdvancedDependency
  2. Click the  icon at the upper left corner of the right pane, then modify the dependency pattern name, for example, change the dependency pattern name to dependency_config.
  3. Click + Level, then select the predefined pattern L1_ospf in this parser as Level 1. 

  4. Click + Level, then select the predefined pattern L2_route_map in this parser as Level 2. 

  5. Click +Add Replace to define Replace for Level 2: Replace B2O in the line patterns in the current level 2 with the values of $route_map_id to get more results according to the values of $route_map_id.

    Information Note: ‘Replace’ can be defined for all Levels except Level 1.
  6.   Click + Level, then select the predefined pattern L3_prefix in this parser as Level 3. 

  7. Click + Add Replace to define replacement for Level 3. Replace B2O in the line patterns of Level 3 with $prefix_list.  
  8. Click to + Add Additional Variable to add a variable by merging the variables $ospf_config, $rout_config and $prefix_config by the Merge String by Line method. Finally, the variable $all_config, which combines the three variables $ospf_config, $rout_config, and $prefix_config, is added. 

    Information Note: For more information about the Add Additional Variable function, see Add Additional Column/Variable in Parser Output Table.
  9. Click the  icon at the upper-right corner to save the parser. The output table of this dependency pattern is as below: