contains operator
Syntax
contains xpath-expression, test-string { info string; err "string"; [err "string";] }
Description
Junos Snapshot Administrator test operator that determines if an XML element string value contains the provided test-string value.
Parameters
err string | Statement generated when the test case returns false. |
info string | Description of the test case. |
test-string | String searched for in the XML element value. Enclose the string in quotation marks. |
xpath-expression | XPath expression selecting the elements to evaluate. |
Usage Examples
Given the following partial XML output from the show version
operational mode command:
<multi-routing-engine-results> <multi-routing-engine-item> <re-name>re0</re-name> <software-information> <host-name>R1</host-name> <product-model>mx960</product-model> <product-name>mx960</product-name> <package-information> <name>junos</name> <comment>JUNOS Base OS boot [10.4R7.5]</comment> </package-information> <package-information> <name>jbase</name> <comment>JUNOS Base OS Software Suite [10.4R7.5]</comment> </package-information> ...
The following test case selects the first package-information
node set, and checks the child comment
element for a Junos OS release number of 10.4.
If the 10.4 release string is not found, the code generates the error
message. The error string includes the comment value containing the
release number found on that Routing Engine.
version-check { command show version invoke-on all-routing-engines; iterate //software-information { contains package-information[1]/comment, "10.4R" { info Checking Junos version for 10.4 release; err "Found %s on RE %s", package-information[1]/comment, ../re-name; } } }
Release Information
Operator introduced in Junos Snapshot Administrator Release 1.0.