Document toolboxDocument toolbox

Configuration File Check Elements

Raw XML rules can use method calls running_config_text and saved_config_text to directly analyze configuration files. They may also use the same constructs used by the Simple Rule and CPD Rule editors (the <ConfigFileCheck> and <CPDCheck> elements, respectively).
<ConfigFileCheck> and <CPDCheck> elements also count as "expressions." They may be used anywhere an <Expr> element can be used. These elements can validate running configuration files and saved configuration files.

<ConfigFileCheck>

Contents of this element will be treated as one or more regular expressions, and validated against the configuration file. When a match is found, the variables "_message" and "_lineno" will be set, appropriate to the type of check being performed.
The ConfigFileCheck element supports the following attributes:

Attribute

Description

object

The name of a variable holding the device object to check. Generally this may be omitted, because the current object is known as part of the context.

regexp_mode

Advanced or Basic. The default is Advanced mode. In basic mode, each line is simply treated as a complete regular expression. In advanced mode, if any line starts with '/', that line will be interpreted as /regex/options. That is, you must have an ending /, and can include regular expression options (zero or more of m, x, i) after the ending /. Lines not starting with / will behave the same as basic mode.

op

Defines the type of config file check to perform. The contents (text node) of the  <ConfigFileSearch> element will be interpreted depending upon the operator:
Single-Line Operations – For these operators, the contents of the element will be split, and each line will be treated as a separate regular expression:

  • contains-one: the configuration file must contain exactly one line matching any of the regular expressions;

  • contains-some: the configuration file must contain at least one line matching one or more of the regular expressions;

  • contains-all: the configuration file must contain at least one line matching each of the regular expressions;

  • contains-all-ordered: the configuration file must contain at least one line matching each of the regular expressions, in the same order as the regular expressions are listed;

  • does-not-contain-any: the configuration file must contain no lines matching any of the regular expressions.

Block Operations – For these operators, the entire contents of the ConfigFileCheck are treated as a single multi-line regular expression:

  • contains-one-block: the configuration file must contain exactly one block matching the regular expression;

  • contains-block: the configuration file must contain at least one block matching the regular expression;

  • does-not-contain-block: the configuration file must contain no matches for the regular expressions.

Configuration Policy Definition Checks (<CPDCheck>)

Statements encapsulated in the <CPDCheck> element are treated by the RAW XML Editor as a simple configuration policy definition (CPD).
Definition of CPDs is discussed further in the topic Using the CPD Editor.

Â