Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Using Junos Snapshot Administrator in Python

 

You can use Junos Snapshot Administrator in Python (jsnapy) on a device running Junos OS to capture and save a runtime environment snapshot, compare two snapshots, or capture a snapshot and immediately evaluate it.

When you take a snapshot, you provide a snapshot name. Jsnapy uses the snapshot name, target device name from the configuration.yml or device.yml file, and test file test section strings to generate snapshot filenames that uniquely identify that snapshot. For example, say you are collecting data from device junos-device.example.com, you define the snapshot name SNAP1, and your test file has two test sections named ospf-checks and bgp-checks. When you take a snapshot, Junos Snapshot Administrator creates the following output files:

  • junos-device.example.com_SNAP1_ospf_checks.xml

  • junos-device.example.com_SNAP1_bgp_checks.xml

The snapshot files are stored on the jsnapy server in the location specified by the snapshot_path parameter in the YAML file /etc/jsnapy/jsnapy.cfg. By default, the location is /etc/jsnapy/snapshots.

The following sections outline the Junos Snapshot Administrator commands:

Taking a Snapshot

To take a snapshot of a device, enter the following on the jsnapy server’s command line:

The command parameters are:

  • snapshot-name—String used in the output filenames to uniquely identify that snapshot.

  • configuration-filename—Snapshot configuration filename.

For example, prior to a maintenance upgrade, user bsmith takes a snapshot of the device. The snapshot name is preupgrade and the configuration filename is config-snapshot.conf. Since bsmith did not specify his password in the configuration file config-snapshot.yml, upon connecting, the device prompts for the user’s password.

Comparing Two Snapshots

To compare two existing snapshots using the test criteria, enter the following on the jsnapy server’s command line:

The command parameters are:

  • snapshot1–String used in the output filename to uniquely identify the first snapshot. Often this is entered as PRE, preupgrage, pre-change, or some name to denote that this snapshot came first.

  • snapshot2—String used in the output filename to uniquely identify the second snapshot. Often this is entered as POST, postupgrage, post-change, or some name to denote that this snapshot came second.

  • configuration-filename–Snapshot configuration file name.

For example, prior to and immediately following a maintenance upgrade, user bsmith takes a snapshot of the device. The snapshot names are preupgrade and postupgrade. To compare these two snapshots using the criteria defined in the configuration file config-snapshot.yml, bsmith issues the following command:

The Junos Snapshot Administrator output displays the target router and the test results for each of the active test sections in the configuration file. Sample output is shown here:

Taking and Evaluating a Snapshot

To take a snapshot and immediately evaluate it based on a pre-defined set of criteria, enter the following on the jsnapy server’s command line:

The command parameters are:

  • snapshot-name—String used in the output filenames to uniquely identify that snapshot.

  • configuration-filename—Snapshot configuration filename.

For example, a user wants to confirm the number of software packages installed on the router junos-device.example.com. To do this, he runs the following command on the jsnapy server’s command line:

The Junos Snapshot Administrator output displays the target router and the test results for each of the active test sections in the configuration file. Sample output is shown here: