Skip to content

Connection Rules

Connection rules are used to transform a linear list of objects returned by the get_inventory script into a tree structure by organizing the appropriate connections.

nameStringRule name
is_builtinBooleanFlag indicating synchronization with the distribution
contextListDescription of contexts
typeStringObject type (returned by get_inventory)
scopeStringThe name of the scope type associated with this type
reset_scopesStringListA list of scope names that need to be reset
rules ListObjectList of rules
match_typeStringThe type for which the rule is applicable
match_connectionStringThe name of the connection to be linked with another object when the rule is triggered. Variables from the context may be included in the name within curly braces (e.g., {variable})
scopeStringThe scope in which the match is performed. By default, the search is performed from the current object to the end of the list of get_inventory objects. If the scope name starts with a minus sign (-), the search is performed in reverse order
target_typeStringThe type of the object to connect with the current object
target_numberStringIf specified, the object is connected not to the first one encountered but to the one with a specific number
target_connectionStringThe name of the connection on the other side to be linked when the rule is triggered. Variables from the context may be included in the name within curly braces (e.g., {variable})

Algorithm for Finding Matches:

For each object from get_inventory:

  • For all rules where match_type matches the object type:
    • If the scope starts with a minus sign (-), search from the current object to the beginning of the object list; otherwise, search from the current object to the end. Find an object with a type matching target_type. If target_number is specified, check the object number as well. The scope variable in the context must match.
    • If we find an object:
      • Expand the names match_connection and target_connection.
      • If the corresponding connections exist on both objects, connect them, and move on to the next object.
    • Check the next rule.


A switch with sfp, and the sfp modules should be connected to the chassis using the connection GiX_sfp, where X is the port number.

Output from get_inventory:


Context settings:

TypeScopeReset Scope



On the first pass through the list of objects, the following context values will be generated:


As a result, the rule will trigger for the transceivers, and the following connections will be created:

XCVR 25inCHASSIS 1Gi25_sfp
XCVR 26inCHASSIS 1Gi26_sfp