Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Understanding Junos Snapshot Administrator Test Operators

Junos Snapshot Administrator enables you to capture and audit runtime environment snapshots of your networked devices running Junos OS. The Junos Snapshot Administrator configuration file defines the scope of a snapshot and the evaluation criteria for either a single snapshot or a comparison of two snapshots. The Junos Snapshot Administrator --snapcheck option takes a single snapshot and evaluates the results, and the --check option compares the results of two separate snapshots. Within the configuration file, you can create test cases that evaluate or compare content from specific Junos OS operational mode commands. The test cases use test operators to either evaluate data elements in a single snapshot or compare data elements in two separate snapshots.

Junos Snapshot Administrator provides numerous relational operators that test for existence, equality, inequality, size, and inclusion in or exclusion from a specific range or list. Specific operators work with different operand types including strings, numbers, and XML elements. You should construct test cases using test operators that pertain to the type of check being performed. For a list of available operators, see Junos Snapshot Administrator Test Operators Summary.

Junos Snapshot Administrator uses a few test operators, delta, list-no-less, list-no-more, and no-diff, to compare elements or element values in two separate snapshots. Test cases using these test operators are executed when you use the --check option. When you use the --snapcheck option, which is specific to a single collection, test cases using these test operators are effectively ignored. Junos Snapshot Administrator outputs a message when a test case is ignored, as shown in the following sample output:

When comparing element values across two snapshots, in order to map the first snapshot data item to the second snapshot data item, you must select elements of the data that create a unique ID. To create a unique ID for a test case, you include the id statement followed by an XPath expression that references the unique element. To create a unique ID based on multiple element values, you define multiple id statements. You can also construct ID values relative to the content value.

Consider the following XML data for the show ospf neighbor operational mode command.

For this case, you can create a unique ID using the value of the interface-name element, which is a child element of ospf-neighbor. You specify the ID using the id statement followed by the interface-name XPath expression.

To create a unique ID based on multiple element values, you define multiple id statements. The following example uniquely identifies an OSPF neighbor by the values of both the interface-name and the neighbor-id elements:

You can also construct ID values relative to the content value. The following example creates a unique ID for a VPLS connection using three values: the VPLS instance-name, the local-site-id within the VPLS service, and the connection-id of the connection.

The previous code defines the content data as the set of connection items, which are selected by the XPath expression instance//connection. Each connection has a connection-id, which defines the first id value. Each connection has a parent element local-site, which has a local-site-id child element. Therefore, the second id value is ../local-site-id. The third id value, ancestor::instance/instance-name, is an XPath expression that means: starting from the connection, go up through the XML parent hierarchy (ancestor) until you find the instance element, and then select the instance-name value. The result is the VPLS service name.

Junos Snapshot Administrator uses special $ID.num variables that map to the id statements in a test section. When you define one or more id statements in a test section, you can use these variables to refer to the XPath expression throughout that test case. This is useful when the XPath expression gets too long. Note the use of the $ID variables in the err statements in the previous example. For more information about Junos Snapshot Administrator variables, see Understanding Junos Snapshot Administrator Reference Variables.