Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Example: Creating the Junos Snapshot Administrator in Python Test Files

This example demonstrates how to create some basic Junos Snapshot Administrator in Python (jsnapy) test files. The examples in this topic use specific numbers of spaces sometimes before any other text is entered on a line. These spaces are required for proper formatting of the YAML file.

Requirements

  • Junos Snapshot Administrator in Python Release 1.0 is installed on the server.

Overview

This topic describes how to create two test files using various elements available for test file creation:

  • A test file named test_sw_version.yml that just captures the Junos OS software release version

  • A test file named filter_config_info.yml that requests filtered information from the get_config RPC command.

Jsnapy test files contain the detailed commands, tests, hierarchy locations, and test elements necessary to create or compare snapshots of the runtime environments of Junos OS devices. You can create as many test files as you want, store them wherever you want on the jsnapy server, and name them as you see fit (with the exception of spaces and special characters). There are two primary parts to a jsnapy test file: the named list of tests under a tests_include heading, and the detail sections, one detail section for each named test under the tests_include section.

Comments can be inserted into the test file at any location by starting the comment with the pound sign (#).

Capture Junos OS Software Release Version

Procedure

Step-by-Step Procedure

For this example, use a text editor to create a new file named test_sw_version.yml. Create the file in the same directory as the configuration file that you intend to use or in the /etc/jsnapy/testfiles/ directory.

  1. Create the tests_include section.

  2. Set the test name.

  3. Start the test details section.

  4. Set the command to be sent. In this case it is the Junos OS command show version.

  5. Specify whether your tests look for the first instance of a value or all instances of a value. In this case we are looking for only the first instance.

  6. Specify the XPATH location from which to start the snapshot or search.

  7. Begin the tests section, if there is one. In this case there will be a tests section.

  8. Specify what tests will be run. In this case we will enable this test file to check whether the Junos OS version is the same between snapshots.

  9. Set the error message to display. In the even that the test fails, this message will be displayed.

  10. Set the info message to display. In the event that the test succeeds, this message will be displayed.

Results

The resulting test file can be shown in the terminal using the cat command.

Request Filtered Configuration Information

Procedure

Step-by-Step Procedure

This example creates a test file that uses an RPC command, get-config, to retrieve the device configuration. An argument is provided to the RPC command so that jsnapy filters that device configuration information so that the snapshot contains only the filtered information rather than the entire configuration. In this example we will configure the test file to return only the host-name information.

  1. Create the tests_include section.

  2. Set the test name.

  3. Begin the test details section.

  4. Set the RPC command to be used.

  5. Provide the arguments keyword to tell jsnapy that arguments follow.

  6. Enter the argument name and value. In this case we are filtering for the host name.

Results

The resulting configuration can be shown in the terminal using the cat command.